From b0ae4689135d62555cf9bbe55cdd7dddcd2d8f05 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 19 Aug 2013 12:17:08 -0500 Subject: [PATCH] Revert "Merge branch 'superdweebie-rand-bugfix'" This reverts commit 002ce3dee6107f2c71af8e7ce0ed1f43693ddadf, reversing changes made to 0023a96e4756112661c11dbf4e293f4be110809a. Note: we will need to revert this revert when merging develop to master for the 2.3.0 release. See http://git-scm.com/blog/2010/03/02/undoing-merges.html - the section on "Reverting the Revert," for details. --- .coveralls.yml | 1 - .travis.yml | 3 - README.md | 18 +- build.xml | 24 +- composer.json | 25 +- library/Zend/Authentication/Adapter/Http.php | 41 +- library/Zend/Authentication/composer.json | 14 +- library/Zend/Barcode/composer.json | 3 - library/Zend/Cache/Storage/Adapter/Apc.php | 15 - .../Zend/Cache/Storage/Adapter/BlackHole.php | 502 ------- .../Cache/Storage/AdapterPluginManager.php | 1 - library/Zend/Cache/StorageFactory.php | 9 - library/Zend/Cache/composer.json | 3 +- library/Zend/Captcha/composer.json | 10 +- library/Zend/Code/composer.json | 6 +- library/Zend/Config/Factory.php | 36 +- library/Zend/Config/Reader/JavaProperties.php | 139 -- library/Zend/Config/composer.json | 8 - .../Zend/Console/Adapter/AbstractAdapter.php | 26 - .../RouteMatcher/DefaultRouteMatcher.php | 781 ---------- .../RouteMatcher/RouteMatcherInterface.php | 23 - library/Zend/Db/composer.json | 9 +- library/Zend/Di/composer.json | 6 - library/Zend/EventManager/ProvidesEvents.php | 3 - library/Zend/Feed/composer.json | 9 - library/Zend/File/composer.json | 10 - library/Zend/Filter/FilterPluginManager.php | 1 - library/Zend/Filter/composer.json | 12 +- library/Zend/Form/Element.php | 38 +- library/Zend/Form/Element/Checkbox.php | 9 +- library/Zend/Form/Element/DateSelect.php | 12 - library/Zend/Form/Element/DateTimeSelect.php | 15 - library/Zend/Form/Element/MonthSelect.php | 11 - library/Zend/Form/Element/MultiCheckbox.php | 32 +- library/Zend/Form/FormElementManager.php | 58 - .../Zend/Form/LabelOptionsAwareInterface.php | 43 - library/Zend/Form/LabelOptionsAwareTrait.php | 73 - library/Zend/Form/View/Helper/FormLabel.php | 7 +- library/Zend/Form/View/Helper/FormRow.php | 15 +- library/Zend/Form/composer.json | 17 - library/Zend/Http/Header/ContentType.php | 338 +---- .../Http/Header/Exception/DomainException.php | 14 - library/Zend/I18n/Filter/NumberFormat.php | 144 +- library/Zend/I18n/Filter/NumberParse.php | 163 -- .../Translator/Loader/AbstractFileLoader.php | 82 -- .../Zend/I18n/Translator/Loader/Gettext.php | 9 +- library/Zend/I18n/Translator/Loader/Ini.php | 10 +- .../Zend/I18n/Translator/Loader/PhpArray.php | 10 +- .../I18n/Translator/LoaderPluginManager.php | 33 - library/Zend/I18n/composer.json | 12 - library/Zend/InputFilter/ArrayInput.php | 4 +- library/Zend/InputFilter/Input.php | 26 +- library/Zend/InputFilter/composer.json | 3 - library/Zend/Json/Encoder.php | 5 - library/Zend/Json/composer.json | 5 - library/Zend/Ldap/composer.json | 6 - library/Zend/Loader/composer.json | 3 + library/Zend/Log/Filter/Sample.php | 57 - library/Zend/Log/LoggerAwareInterface.php | 14 - library/Zend/Log/LoggerAwareTrait.php | 10 - library/Zend/Log/composer.json | 9 - library/Zend/Mail/composer.json | 8 +- library/Zend/Math/Rand.php | 2 - library/Zend/Math/composer.json | 9 +- library/Zend/Memory/composer.json | 6 - library/Zend/Mime/composer.json | 6 - .../ModuleManager/Listener/ConfigListener.php | 24 +- library/Zend/ModuleManager/ModuleEvent.php | 9 +- library/Zend/ModuleManager/composer.json | 9 - library/Zend/Mvc/Application.php | 10 +- .../Mvc/Controller/Plugin/FlashMessenger.php | 83 -- library/Zend/Mvc/Router/Console/Simple.php | 715 ++++++++- .../View/Console/DefaultRenderingStrategy.php | 14 +- library/Zend/Mvc/composer.json | 28 +- library/Zend/Navigation/Page/Uri.php | 55 - .../Service/AbstractNavigationFactory.php | 20 +- library/Zend/Navigation/composer.json | 9 - .../Zend/Paginator/Adapter/DbTableGateway.php | 24 +- library/Zend/Paginator/composer.json | 16 - library/Zend/ProgressBar/composer.json | 7 +- library/Zend/Serializer/composer.json | 3 - library/Zend/ServiceManager/composer.json | 3 - library/Zend/Session/composer.json | 11 - library/Zend/Soap/composer.json | 6 - .../Zend/Stdlib/Hydrator/AbstractHydrator.php | 2 +- .../Hydrator/FilterEnabledInterface.php | 63 - .../Stdlib/Hydrator/HydratorAwareTrait.php | 49 - library/Zend/Stdlib/JsonSerializable.php | 28 - .../PhpLegacyCompatibility.php | 28 - library/Zend/Stdlib/composer.json | 14 +- .../Zend/Tag/Cloud/Decorator/HtmlCloud.php | 2 +- library/Zend/Tag/composer.json | 6 - library/Zend/Test/composer.json | 6 - library/Zend/Validator/NotEmpty.php | 53 +- library/Zend/Validator/composer.json | 9 +- library/Zend/Version/Version.php | 173 +-- library/Zend/Version/composer.json | 6 +- library/Zend/View/Helper/FlashMessenger.php | 1 - library/Zend/View/Helper/HeadLink.php | 6 +- library/Zend/View/Helper/HeadMeta.php | 4 - library/Zend/View/Helper/HeadScript.php | 4 - library/Zend/View/Helper/HeadStyle.php | 6 +- library/Zend/View/composer.json | 28 +- .../Authentication/Adapter/HttpTest.php | 52 - .../Cache/Storage/Adapter/BlackHoleTest.php | 155 -- tests/ZendTest/Cache/StorageFactoryTest.php | 10 - tests/ZendTest/Config/FactoryTest.php | 23 - .../Config/Reader/JavaPropertiesTest.php | 79 - .../JavaProperties/include-base.properties | 3 - .../JavaProperties/include-target.properties | 3 - .../Console/Adapter/AbstractAdapterTest.php | 26 +- .../RouteMatcher/DefaultRouteMatcherTest.php | 1308 ----------------- .../ZendTest/Form/Element/DateSelectTest.php | 8 - .../Form/Element/DateTimeSelectTest.php | 8 - .../ZendTest/Form/Element/MonthSelectTest.php | 7 - .../Form/Element/MultiCheckboxTest.php | 14 - tests/ZendTest/Form/ElementTest.php | 17 +- .../ZendTest/Form/FormElementManagerTest.php | 42 - .../Form/View/Helper/FormDateTest.php | 4 - .../Form/View/Helper/FormInputTest.php | 31 +- .../ZendTest/Form/View/Helper/FormRowTest.php | 25 - tests/ZendTest/Http/Header/AcceptTest.php | 6 +- .../ZendTest/Http/Header/ContentTypeTest.php | 90 +- .../Http/Response/ResponseStreamTest.php | 2 +- tests/ZendTest/Http/ResponseTest.php | 2 +- .../ZendTest/I18n/Filter/NumberFormatTest.php | 1 + .../ZendTest/I18n/Filter/NumberParseTest.php | 77 - .../I18n/Translator/Loader/GettextTest.php | 28 +- .../I18n/Translator/Loader/IniTest.php | 31 +- .../I18n/Translator/Loader/PhpArrayTest.php | 28 +- .../I18n/Translator/_files/translations.phar | Bin 9664 -> 0 bytes tests/ZendTest/InputFilter/ArrayInputTest.php | 33 - tests/ZendTest/InputFilter/FileInputTest.php | 5 - tests/ZendTest/InputFilter/InputTest.php | 30 - tests/ZendTest/Json/JsonTest.php | 24 +- .../TestAsset/JsonSerializableBuiltinImpl.php | 26 - .../Json/TestAsset/JsonSerializableZFImpl.php | 21 - tests/ZendTest/Log/Filter/SampleTest.php | 62 - .../Listener/ConfigListenerTest.php | 2 +- .../Listener/DefaultListenerAggregateTest.php | 2 +- tests/ZendTest/Mvc/ApplicationTest.php | 8 +- .../Mvc/Controller/ControllerManagerTest.php | 4 +- .../Mvc/Controller/Plugin/RedirectTest.php | 6 - .../Mvc/Router/Console/SimpleTest.php | 986 ++++++++++++- .../Console/DefaultRenderingStrategyTest.php | 12 - tests/ZendTest/Navigation/Page/UriTest.php | 35 - .../Paginator/Adapter/DbTableGatewayTest.php | 54 +- .../Hydrator/HydratorAwareTraitTest.php | 45 - tests/ZendTest/Tag/Cloud/CloudTest.php | 181 +-- .../Tag/Cloud/Decorator/HtmlCloudTest.php | 139 +- .../Validator/File/IsCompressedTest.php | 5 - tests/ZendTest/Validator/File/IsImageTest.php | 5 - tests/ZendTest/Validator/NotEmptyTest.php | 18 +- tests/ZendTest/Version/VersionTest.php | 102 +- .../View/Helper/FlashMessengerTest.php | 6 - tests/ZendTest/View/Helper/HeadLinkTest.php | 26 - tests/ZendTest/View/Helper/HeadMetaTest.php | 15 - tests/ZendTest/View/Helper/HeadScriptTest.php | 24 - tests/ZendTest/View/Helper/HeadStyleTest.php | 22 - 159 files changed, 2080 insertions(+), 6488 deletions(-) delete mode 100644 .coveralls.yml delete mode 100644 library/Zend/Cache/Storage/Adapter/BlackHole.php delete mode 100644 library/Zend/Config/Reader/JavaProperties.php delete mode 100644 library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php delete mode 100644 library/Zend/Console/RouteMatcher/RouteMatcherInterface.php delete mode 100644 library/Zend/Form/LabelOptionsAwareInterface.php delete mode 100644 library/Zend/Form/LabelOptionsAwareTrait.php delete mode 100644 library/Zend/Http/Header/Exception/DomainException.php delete mode 100644 library/Zend/I18n/Filter/NumberParse.php delete mode 100644 library/Zend/I18n/Translator/Loader/AbstractFileLoader.php delete mode 100644 library/Zend/Log/Filter/Sample.php delete mode 100644 library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php delete mode 100644 library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php delete mode 100644 library/Zend/Stdlib/JsonSerializable.php delete mode 100644 library/Zend/Stdlib/JsonSerializable/PhpLegacyCompatibility.php delete mode 100644 tests/ZendTest/Authentication/Adapter/HttpTest.php delete mode 100644 tests/ZendTest/Cache/Storage/Adapter/BlackHoleTest.php delete mode 100644 tests/ZendTest/Config/Reader/JavaPropertiesTest.php delete mode 100644 tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-base.properties delete mode 100644 tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-target.properties delete mode 100644 tests/ZendTest/Console/RouteMatcher/DefaultRouteMatcherTest.php delete mode 100644 tests/ZendTest/I18n/Filter/NumberParseTest.php delete mode 100644 tests/ZendTest/I18n/Translator/_files/translations.phar delete mode 100644 tests/ZendTest/Json/TestAsset/JsonSerializableBuiltinImpl.php delete mode 100644 tests/ZendTest/Json/TestAsset/JsonSerializableZFImpl.php delete mode 100644 tests/ZendTest/Log/Filter/SampleTest.php delete mode 100644 tests/ZendTest/Stdlib/Hydrator/HydratorAwareTraitTest.php diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 2067cef8ecc..00000000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -src_dir: library diff --git a/.travis.yml b/.travis.yml index 6d96b2fc27d..7329bdb9d0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,6 @@ before_install: script: - ant travis -keep-going -after_script: - - php vendor/bin/coveralls - notifications: irc: "irc.freenode.org#zftalk.dev" email: false diff --git a/README.md b/README.md index d4bcbd52470..f960c51aa76 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,17 @@ -### Welcome to the *Zend Framework 2.3* Release! +### Welcome to the *Zend Framework 2.2* Release! -Master: -[![Build Status](https://secure.travis-ci.org/zendframework/zf2.png?branch=master)](http://travis-ci.org/zendframework/zf2) -[![Coverage Status](https://coveralls.io/repos/zendframework/zf2/badge.png?branch=master)](https://coveralls.io/r/zendframework/zf2) -Develop: -[![Build Status](https://secure.travis-ci.org/zendframework/zf2.png?branch=develop)](http://travis-ci.org/zendframework/zf2) -[![Coverage Status](https://coveralls.io/repos/zendframework/zf2/badge.png?branch=develop)](https://coveralls.io/r/zendframework/zf2) +Master: [![Build Status](https://secure.travis-ci.org/zendframework/zf2.png?branch=master)](http://travis-ci.org/zendframework/zf2) +Develop: [![Build Status](https://secure.travis-ci.org/zendframework/zf2.png?branch=develop)](http://travis-ci.org/zendframework/zf2) ## RELEASE INFORMATION -*Zend Framework 2.3.0dev* +*Zend Framework 2.2.3dev* -This is the third minor (feature) release for the version 2 series. +This is the third maintenance release for the 2.2 series. -DD MMM YYY +DD MMM YYYY -### UPDATES IN 2.3.0 +### UPDATES IN 2.2.3 Please see [CHANGELOG.md](CHANGELOG.md). diff --git a/build.xml b/build.xml index a138d4b4b52..3d836c7261a 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + @@ -9,8 +9,6 @@ - - @@ -26,7 +24,7 @@ - + @@ -34,22 +32,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/composer.json b/composer.json index 2bad4e43fa6..b165a6b9b04 100644 --- a/composer.json +++ b/composer.json @@ -8,27 +8,6 @@ ], "homepage": "http://framework.zend.com/", "license": "BSD-3-Clause", - "repositories": [ - { - "type": "package", - "package": { - "name": "sebastianbergmann/phpcov", - "version": "1.1.0", - "dist": { - "url": "https://github.com/sebastianbergmann/phpcov/archive/1.1.0.zip", - "type": "zip" - }, - "source": { - "url": "https://github.com/sebastianbergmann/phpcov.git", - "type": "git", - "reference": "1.1.0" - }, - "bin": [ - "phpcov.php" - ] - } - } - ], "require": { "php": ">=5.3.3" }, @@ -37,9 +16,7 @@ "ircmaxell/random-lib": "dev-master", "ircmaxell/security-lib": "dev-master", "ocramius/proxy-manager": "0.4.*", - "phpunit/PHPUnit": "3.7.*", - "satooshi/php-coveralls": "dev-master", - "sebastianbergmann/phpcov": "1.1.0" + "phpunit/PHPUnit": "3.7.*" }, "suggest": { "ext-intl": "ext/intl for i18n features (included in default builds of PHP)", diff --git a/library/Zend/Authentication/Adapter/Http.php b/library/Zend/Authentication/Adapter/Http.php index 23125648bac..d5e2fbfa227 100644 --- a/library/Zend/Authentication/Adapter/Http.php +++ b/library/Zend/Authentication/Adapter/Http.php @@ -336,11 +336,11 @@ public function authenticate() $headers = $this->request->getHeaders(); if (!$headers->has($getHeader)) { - return $this->challengeClient(); + return $this->_challengeClient(); } $authHeader = $headers->get($getHeader)->getFieldValue(); if (!$authHeader) { - return $this->challengeClient(); + return $this->_challengeClient(); } list($clientScheme) = explode(' ', $authHeader); @@ -360,7 +360,7 @@ public function authenticate() // client sent a scheme that is not the one required if (!in_array($clientScheme, $this->acceptSchemes)) { // challenge again the client - return $this->challengeClient(); + return $this->_challengeClient(); } switch ($clientScheme) { @@ -377,23 +377,6 @@ public function authenticate() return $result; } - /** - * @deprecated - * @see Http::challengeClient() - * @return Authentication\Result Always returns a non-identity Auth result - */ - protected function _challengeClient() - { - trigger_error(sprintf( - 'The method "%s" is deprecated and will be removed in the future; ' - . 'please use the public method "%s::challengeClient()" instead', - __METHOD__, - __CLASS__ - ), E_USER_DEPRECATED); - - return $this->challengeClient(); - } - /** * Challenge Client * @@ -402,7 +385,7 @@ protected function _challengeClient() * * @return Authentication\Result Always returns a non-identity Auth result */ - public function challengeClient() + protected function _challengeClient() { if ($this->imaProxy) { $statusCode = 407; @@ -491,12 +474,12 @@ protected function _basicAuth($header) // implementation does. If invalid credentials are detected, // re-challenge the client. if (!ctype_print($auth)) { - return $this->challengeClient(); + return $this->_challengeClient(); } // Fix for ZF-1515: Now re-challenges on empty username or password $creds = array_filter(explode(':', $auth)); if (count($creds) != 2) { - return $this->challengeClient(); + return $this->_challengeClient(); } $result = $this->basicResolver->resolve($creds[0], $this->realm, $creds[1]); @@ -515,7 +498,7 @@ protected function _basicAuth($header) return new Authentication\Result(Authentication\Result::SUCCESS, $result); } - return $this->challengeClient(); + return $this->_challengeClient(); } /** @@ -547,17 +530,17 @@ protected function _digestAuth($header) // See ZF-1052. This code was a bit too unforgiving of invalid // usernames. Now, if the username is bad, we re-challenge the client. if ('::invalid::' == $data['username']) { - return $this->challengeClient(); + return $this->_challengeClient(); } // Verify that the client sent back the same nonce if ($this->_calcNonce() != $data['nonce']) { - return $this->challengeClient(); + return $this->_challengeClient(); } // The opaque value is also required to match, but of course IE doesn't // play ball. if (!$this->ieNoOpaque && $this->_calcOpaque() != $data['opaque']) { - return $this->challengeClient(); + return $this->_challengeClient(); } // Look up the user's password hash. If not found, deny access. @@ -566,7 +549,7 @@ protected function _digestAuth($header) // to be recreatable with the current settings of this object. $ha1 = $this->digestResolver->resolve($data['username'], $data['realm']); if ($ha1 === false) { - return $this->challengeClient(); + return $this->_challengeClient(); } // If MD5-sess is used, a1 value is made of the user's password @@ -605,7 +588,7 @@ protected function _digestAuth($header) return new Authentication\Result(Authentication\Result::SUCCESS, $identity); } - return $this->challengeClient(); + return $this->_challengeClient(); } /** diff --git a/library/Zend/Authentication/composer.json b/library/Zend/Authentication/composer.json index 855387833eb..bdcc937935a 100644 --- a/library/Zend/Authentication/composer.json +++ b/library/Zend/Authentication/composer.json @@ -16,23 +16,11 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-db": "self.version", - "zendframework/zend-crypt": "self.version", - "zendframework/zend-http": "self.version", - "zendframework/zend-ldap": "self.version", - "zendframework/zend-session": "self.version", - "zendframework/zend-validator": "self.version", - "zendframework/zend-uri": "self.version" - }, "suggest": { "zendframework/zend-db": "Zend\\Db component", "zendframework/zend-crypt": "Zend\\Crypt component", - "zendframework/zend-http": "Zend\\Http component", - "zendframework/zend-ldap": "Zend\\Ldap component", - "zendframework/zend-session": "Zend\\Session component", "zendframework/zend-uri": "Zend\\Uri component", - "zendframework/zend-validator": "Zend\\Validator component" + "zendframework/zend-session": "Zend\\Session component" }, "extra": { "branch-alias": { diff --git a/library/Zend/Barcode/composer.json b/library/Zend/Barcode/composer.json index 86e19c6d421..798049be296 100644 --- a/library/Zend/Barcode/composer.json +++ b/library/Zend/Barcode/composer.json @@ -17,12 +17,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-validator": "self.version", "zendframework/zendpdf": "*" }, "suggest": { - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", "zendframework/zend-validator": "Zend\\Validator component", "zendframework/zendpdf": "ZendPdf component" }, diff --git a/library/Zend/Cache/Storage/Adapter/Apc.php b/library/Zend/Cache/Storage/Adapter/Apc.php index 8f4ecf0d9f5..2196ff5f43e 100644 --- a/library/Zend/Cache/Storage/Adapter/Apc.php +++ b/library/Zend/Cache/Storage/Adapter/Apc.php @@ -734,19 +734,4 @@ protected function normalizeMetadata(array & $metadata) $metadata['num_hits'] ); } - - /** - * Internal method to set an item only if token matches - * - * @param mixed $token - * @param string $normalizedKey - * @param mixed $value - * @return bool - * @see getItem() - * @see setItem() - */ - protected function internalCheckAndSetItem(& $token, & $normalizedKey, & $value) - { - return apc_cas($normalizedKey, $token, $value); - } } diff --git a/library/Zend/Cache/Storage/Adapter/BlackHole.php b/library/Zend/Cache/Storage/Adapter/BlackHole.php deleted file mode 100644 index 52b0309ceba..00000000000 --- a/library/Zend/Cache/Storage/Adapter/BlackHole.php +++ /dev/null @@ -1,502 +0,0 @@ -setOptions($options); - } - } - - /** - * Set options. - * - * @param array|Traversable|Adapter\AdapterOptions $options - * @return StorageInterface Fluent interface - */ - public function setOptions($options) - { - if ($this->options !== $options) { - if (!$options instanceof AdapterOptions) { - $options = new AdapterOptions($options); - } - - if ($this->options) { - $this->options->setAdapter(null); - } - $options->setAdapter($this); - $this->options = $options; - } - return $this; - } - - /** - * Get options - * - * @return Adapter\AdapterOptions - */ - public function getOptions() - { - if (!$this->options) { - $this->setOptions(new AdapterOptions()); - } - return $this->options; - } - - /** - * Get an item. - * - * @param string $key - * @param bool $success - * @param mixed $casToken - * @return mixed Data on success, null on failure - */ - public function getItem($key, & $success = null, & $casToken = null) - { - $success = false; - return null; - } - - /** - * Get multiple items. - * - * @param array $keys - * @return array Associative array of keys and values - */ - public function getItems(array $keys) - { - return array(); - } - - /** - * Test if an item exists. - * - * @param string $key - * @return bool - */ - public function hasItem($key) - { - return false; - } - - /** - * Test multiple items. - * - * @param array $keys - * @return array Array of found keys - */ - public function hasItems(array $keys) - { - return array(); - } - - /** - * Get metadata of an item. - * - * @param string $key - * @return array|bool Metadata on success, false on failure - */ - public function getMetadata($key) - { - return false; - } - - /** - * Get multiple metadata - * - * @param array $keys - * @return array Associative array of keys and metadata - */ - public function getMetadatas(array $keys) - { - return array(); - } - - /** - * Store an item. - * - * @param string $key - * @param mixed $value - * @return bool - */ - public function setItem($key, $value) - { - return false; - } - - /** - * Store multiple items. - * - * @param array $keyValuePairs - * @return array Array of not stored keys - */ - public function setItems(array $keyValuePairs) - { - return array_keys($keyValuePairs); - } - - /** - * Add an item. - * - * @param string $key - * @param mixed $value - * @return bool - */ - public function addItem($key, $value) - { - return false; - } - - /** - * Add multiple items. - * - * @param array $keyValuePairs - * @return array Array of not stored keys - */ - public function addItems(array $keyValuePairs) - { - return array_keys($keyValuePairs); - } - - /** - * Replace an existing item. - * - * @param string $key - * @param mixed $value - * @return bool - */ - public function replaceItem($key, $value) - { - return false; - } - - /** - * Replace multiple existing items. - * - * @param array $keyValuePairs - * @return array Array of not stored keys - */ - public function replaceItems(array $keyValuePairs) - { - return array_keys($keyValuePairs); - } - - /** - * Set an item only if token matches - * - * It uses the token received from getItem() to check if the item has - * changed before overwriting it. - * - * @param mixed $token - * @param string $key - * @param mixed $value - * @return bool - */ - public function checkAndSetItem($token, $key, $value) - { - return false; - } - - /** - * Reset lifetime of an item - * - * @param string $key - * @return bool - */ - public function touchItem($key) - { - return false; - } - - /** - * Reset lifetime of multiple items. - * - * @param array $keys - * @return array Array of not updated keys - */ - public function touchItems(array $keys) - { - return $keys; - } - - /** - * Remove an item. - * - * @param string $key - * @return bool - */ - public function removeItem($key) - { - return false; - } - - /** - * Remove multiple items. - * - * @param array $keys - * @return array Array of not removed keys - */ - public function removeItems(array $keys) - { - return $keys; - } - - /** - * Increment an item. - * - * @param string $key - * @param int $value - * @return int|bool The new value on success, false on failure - */ - public function incrementItem($key, $value) - { - return false; - } - - /** - * Increment multiple items. - * - * @param array $keyValuePairs - * @return array Associative array of keys and new values - */ - public function incrementItems(array $keyValuePairs) - { - return array(); - } - - /** - * Decrement an item. - * - * @param string $key - * @param int $value - * @return int|bool The new value on success, false on failure - */ - public function decrementItem($key, $value) - { - return false; - } - - /** - * Decrement multiple items. - * - * @param array $keyValuePairs - * @return array Associative array of keys and new values - */ - public function decrementItems(array $keyValuePairs) - { - return array(); - } - - /** - * Capabilities of this storage - * - * @return Capabilities - */ - public function getCapabilities() - { - if ($this->capabilities === null) { - // use default capabilities only - $this->capabilityMarker = new stdClass(); - $this->capabilities = new Capabilities($this, $this->capabilityMarker); - } - return $this->capabilities; - } - - /* AvailableSpaceCapableInterface */ - - /** - * Get available space in bytes - * - * @return int|float - */ - public function getAvailableSpace() - { - return 0; - } - - /* ClearByNamespaceInterface */ - - /** - * Remove items of given namespace - * - * @param string $namespace - * @return bool - */ - public function clearByNamespace($namespace) - { - return false; - } - - /* ClearByPrefixInterface */ - - /** - * Remove items matching given prefix - * - * @param string $prefix - * @return bool - */ - public function clearByPrefix($prefix) - { - return false; - } - - /* ClearExpiredInterface */ - - /** - * Remove expired items - * - * @return bool - */ - public function clearExpired() - { - return false; - } - - /* FlushableInterface */ - - /** - * Flush the whole storage - * - * @return bool - */ - public function flush() - { - return false; - } - - /* IterableInterface */ - - /** - * Get the storage iterator - * - * @return KeyIterator - */ - public function getIterator() - { - return new KeyListIterator($this, array()); - } - - /* OptimizableInterface */ - - /** - * Optimize the storage - * - * @return bool - */ - public function optimize() - { - return false; - } - - /* TaggableInterface */ - - /** - * Set tags to an item by given key. - * An empty array will remove all tags. - * - * @param string $key - * @param string[] $tags - * @return bool - */ - public function setTags($key, array $tags) - { - return false; - } - - /** - * Get tags of an item by given key - * - * @param string $key - * @return string[]|FALSE - */ - public function getTags($key) - { - return false; - } - - /** - * Remove items matching given tags. - * - * If $disjunction only one of the given tags must match - * else all given tags must match. - * - * @param string[] $tags - * @param bool $disjunction - * @return bool - */ - public function clearByTags(array $tags, $disjunction = false) - { - return false; - } - - /* TotalSpaceCapableInterface */ - - /** - * Get total space in bytes - * - * @return int|float - */ - public function getTotalSpace() - { - return 0; - } -} diff --git a/library/Zend/Cache/Storage/AdapterPluginManager.php b/library/Zend/Cache/Storage/AdapterPluginManager.php index 4a5bc82569e..9f133fb0e94 100644 --- a/library/Zend/Cache/Storage/AdapterPluginManager.php +++ b/library/Zend/Cache/Storage/AdapterPluginManager.php @@ -28,7 +28,6 @@ class AdapterPluginManager extends AbstractPluginManager */ protected $invokableClasses = array( 'apc' => 'Zend\Cache\Storage\Adapter\Apc', - 'blackhole' => 'Zend\Cache\Storage\Adapter\BlackHole', 'dba' => 'Zend\Cache\Storage\Adapter\Dba', 'filesystem' => 'Zend\Cache\Storage\Adapter\Filesystem', 'memcached' => 'Zend\Cache\Storage\Adapter\Memcached', diff --git a/library/Zend/Cache/StorageFactory.php b/library/Zend/Cache/StorageFactory.php index 0cb4fd49625..5779e9d09ba 100644 --- a/library/Zend/Cache/StorageFactory.php +++ b/library/Zend/Cache/StorageFactory.php @@ -10,7 +10,6 @@ namespace Zend\Cache; use Traversable; -use Zend\EventManager\EventsCapableInterface; use Zend\Stdlib\ArrayUtils; abstract class StorageFactory @@ -72,14 +71,6 @@ public static function factory($cfg) // add plugins if (isset($cfg['plugins'])) { - if (!$adapter instanceof EventsCapableInterface) { - throw new Exception\RuntimeException(sprintf( - "The adapter '%s' doesn't implement '%s' and therefore can't handle plugins", - get_class($adapter), - 'Zend\EventManager\EventsCapableInterface' - )); - } - if (!is_array($cfg['plugins'])) { throw new Exception\InvalidArgumentException( 'Plugins needs to be an array' diff --git a/library/Zend/Cache/composer.json b/library/Zend/Cache/composer.json index 4d22e97347a..1d9089ac5eb 100644 --- a/library/Zend/Cache/composer.json +++ b/library/Zend/Cache/composer.json @@ -19,8 +19,7 @@ "zendframework/zend-eventmanager": "self.version" }, "require-dev": { - "zendframework/zend-serializer": "self.version", - "zendframework/zend-session": "self.version" + "zendframework/zend-serializer": "self.version" }, "suggest": { "zendframework/zend-serializer": "Zend\\Serializer component", diff --git a/library/Zend/Captcha/composer.json b/library/Zend/Captcha/composer.json index 908309f5417..35bbd0db503 100644 --- a/library/Zend/Captcha/composer.json +++ b/library/Zend/Captcha/composer.json @@ -18,17 +18,11 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-session": "self.version", - "zendframework/zend-text": "self.version", - "zendframework/zend-validator": "self.version", "zendframework/zendservice-recaptcha": "*" }, "suggest": { - "zendframework/zend-resources": "Translations of captcha messages", - "zendframework/zend-session": "Zend\\Session component", - "zendframework/zend-text": "Zend\\Text component", - "zendframework/zend-validator": "Zend\\Validator component", - "zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha component" + "zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha component", + "zendframework/zend-resources": "Translations of captcha messages" }, "extra": { "branch-alias": { diff --git a/library/Zend/Code/composer.json b/library/Zend/Code/composer.json index 807367acef6..b970e408f9c 100644 --- a/library/Zend/Code/composer.json +++ b/library/Zend/Code/composer.json @@ -17,12 +17,10 @@ "zendframework/zend-eventmanager": "self.version" }, "require-dev": { - "doctrine/common": ">=2.1", - "zendframework/zend-stdlib": "self.version" + "doctrine/common": ">=2.1" }, "suggest": { - "doctrine/common": "Doctrine\\Common >=2.1 for annotation features", - "zendframework/zend-stdlib": "Zend\\Stdlib component" + "doctrine/common": "Doctrine\\Common >=2.1 for annotation features" }, "extra": { "branch-alias": { diff --git a/library/Zend/Config/Factory.php b/library/Zend/Config/Factory.php index 87705c49f0a..d00a6abcd87 100644 --- a/library/Zend/Config/Factory.php +++ b/library/Zend/Config/Factory.php @@ -59,34 +59,13 @@ class Factory * * @param string $filename * @param bool $returnConfigObject - * @param bool $useIncludePath * @return array|Config * @throws Exception\InvalidArgumentException * @throws Exception\RuntimeException */ - public static function fromFile($filename, $returnConfigObject = false, $useIncludePath = false) + public static function fromFile($filename, $returnConfigObject = false) { - $filepath = $filename; - if (!file_exists($filename)) { - if (!$useIncludePath) { - throw new Exception\RuntimeException(sprintf( - 'Filename "%s" cannot be found relative to the working directory', - $filename - )); - } - - $fromIncludePath = stream_resolve_include_path($filename); - if (!$fromIncludePath) { - throw new Exception\RuntimeException(sprintf( - 'Filename "%s" cannot be found relative to the working directory or the include_path ("%s")', - $filename, - get_include_path() - )); - } - $filepath = $fromIncludePath; - } - - $pathinfo = pathinfo($filepath); + $pathinfo = pathinfo($filename); if (!isset($pathinfo['extension'])) { throw new Exception\RuntimeException(sprintf( @@ -98,14 +77,14 @@ public static function fromFile($filename, $returnConfigObject = false, $useIncl $extension = strtolower($pathinfo['extension']); if ($extension === 'php') { - if (!is_file($filepath) || !is_readable($filepath)) { + if (!is_file($filename) || !is_readable($filename)) { throw new Exception\RuntimeException(sprintf( "File '%s' doesn't exist or not readable", $filename )); } - $config = include $filepath; + $config = include $filename; } elseif (isset(static::$extensions[$extension])) { $reader = static::$extensions[$extension]; if (!$reader instanceof Reader\ReaderInterface) { @@ -114,7 +93,7 @@ public static function fromFile($filename, $returnConfigObject = false, $useIncl } /** @var Reader\ReaderInterface $reader */ - $config = $reader->fromFile($filepath); + $config = $reader->fromFile($filename); } else { throw new Exception\RuntimeException(sprintf( 'Unsupported config file extension: .%s', @@ -130,15 +109,14 @@ public static function fromFile($filename, $returnConfigObject = false, $useIncl * * @param array $files * @param bool $returnConfigObject - * @param bool $useIncludePath * @return array|Config */ - public static function fromFiles(array $files, $returnConfigObject = false, $useIncludePath = false) + public static function fromFiles(array $files, $returnConfigObject = false) { $config = array(); foreach ($files as $file) { - $config = ArrayUtils::merge($config, static::fromFile($file, false, $useIncludePath)); + $config = ArrayUtils::merge($config, static::fromFile($file)); } return ($returnConfigObject) ? new Config($config) : $config; diff --git a/library/Zend/Config/Reader/JavaProperties.php b/library/Zend/Config/Reader/JavaProperties.php deleted file mode 100644 index 7c6e8bf9728..00000000000 --- a/library/Zend/Config/Reader/JavaProperties.php +++ /dev/null @@ -1,139 +0,0 @@ -directory = dirname($filename); - - $config = $this->parse(file_get_contents($filename)); - - return $this->process($config); - } - - /** - * fromString(): defined by Reader interface. - * - * @see ReaderInterface::fromString() - * @param string $string - * @return array - * @throws Exception\RuntimeException if an @include key is found - */ - public function fromString($string) - { - if (empty($string)) { - return array(); - } - - $this->directory = null; - - $config = $this->parse($string); - - return $this->process($config); - } - - /** - * Process the array for @include - * - * @param array $data - * @return array - * @throws Exception\RuntimeException if an @include key is found - */ - protected function process(array $data) - { - foreach ($data as $key => $value) { - if (trim($key) === '@include') { - if ($this->directory === null) { - throw new Exception\RuntimeException('Cannot process @include statement for a string'); - } - $reader = clone $this; - unset($data[$key]); - $data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value)); - } - } - return $data; - } - - /** - * Parse Java-style properties string - * - * @todo Support use of the equals sign "key=value" as key-value delimiter - * @todo Ignore whitespace that precedes text past the first line of multiline values - * - * @param string $string - * @return array - */ - protected function parse($string) - { - $result = array(); - $lines = explode("\n", $string); - $key = ""; - $isWaitingOtherLine = false; - foreach ($lines as $i => $line) { - // Ignore empty lines and commented lines - if (empty($line) - || (!$isWaitingOtherLine && strpos($line, "#") === 0) - || (!$isWaitingOtherLine && strpos($line, "!") === 0)) { - continue; - } - - // Add a new key-value pair or append value to a previous pair - if (!$isWaitingOtherLine) { - $key = substr($line, 0, strpos($line, ':')); - $value = substr($line, strpos($line, ':') + 1, strlen($line)); - } else { - $value .= $line; - } - - // Check if ends with single '\' (indicating another line is expected) - if (strrpos($value, "\\") === strlen($value) - strlen("\\")) { - $value = substr($value, 0, strlen($value) - 1); - $isWaitingOtherLine = true; - } else { - $isWaitingOtherLine = false; - } - - $result[$key] = stripslashes($value); - unset($lines[$i]); - } - - return $result; - } -} diff --git a/library/Zend/Config/composer.json b/library/Zend/Config/composer.json index 5b24f88719d..f515b057a3e 100644 --- a/library/Zend/Config/composer.json +++ b/library/Zend/Config/composer.json @@ -16,15 +16,7 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-filter": "self.version", - "zendframework/zend-i18n": "self.version", - "zendframework/zend-json": "self.version", - "zendframework/zend-servicemanager": "self.version" - }, "suggest": { - "zendframework/zend-filter": "Zend\\Filter component", - "zendframework/zend-i18n": "Zend\\I18n component", "zendframework/zend-json": "Zend\\Json to use the Json reader or writer classes", "zendframework/zend-servicemanager": "Zend\\ServiceManager for use with the Config Factory to retrieve reader and writer instances" }, diff --git a/library/Zend/Console/Adapter/AbstractAdapter.php b/library/Zend/Console/Adapter/AbstractAdapter.php index 2cbfd8138e5..5cf5ae9d273 100644 --- a/library/Zend/Console/Adapter/AbstractAdapter.php +++ b/library/Zend/Console/Adapter/AbstractAdapter.php @@ -53,9 +53,6 @@ abstract class AbstractAdapter implements AdapterInterface */ public function write($text, $color = null, $bgColor = null) { - //Encode text to match console encoding - $text = $this->encodeText($text); - if ($color !== null || $bgColor !== null) { echo $this->colorize($text, $color, $bgColor); } else { @@ -500,27 +497,4 @@ public function readChar($mask = null) fclose($f); return $char; } - - /** - * Encode a text to match console encoding - * - * @param string $text - * @return string the encoding text - */ - public function encodeText($text) - { - if ($this->isUtf8()) { - if (StringUtils::isValidUtf8($text)) { - return $text; - } - - return utf8_encode($text); - } - - if (StringUtils::isValidUtf8($text)) { - return utf8_decode($text); - } - - return $text; - } } diff --git a/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php b/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php deleted file mode 100644 index e8972345978..00000000000 --- a/library/Zend/Console/RouteMatcher/DefaultRouteMatcher.php +++ /dev/null @@ -1,781 +0,0 @@ -defaults = $defaults; - $this->constraints = $constraints; - $this->aliases = $aliases; - - if ($filters !== null) { - foreach ($filters as $name => $filter) { - if (!$filter instanceof FilterInterface) { - throw new Exception\InvalidArgumentException('Cannot use ' . gettype($filters) . ' as filter for ' . __CLASS__); - } - $this->filters[$name] = $filter; - } - } - - if ($validators !== null) { - foreach ($validators as $name => $validator) { - if (!$validator instanceof ValidatorInterface) { - throw new Exception\InvalidArgumentException('Cannot use ' . gettype($validator) . ' as validator for ' . __CLASS__); - } - $this->validators[$name] = $validator; - } - } - - $this->parts = $this->parseDefinition($route); - } - - /** - * Parse a route definition. - * - * @param string $def - * @return array - * @throws Exception\InvalidArgumentException - */ - protected function parseDefinition($def) - { - $def = trim($def); - $pos = 0; - $length = strlen($def); - $parts = array(); - $unnamedGroupCounter = 1; - - while ($pos < $length) { - /* - * Mandatory long param - * --param= - * --param=whatever - */ - if (preg_match('/\G--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+)(?P=\S*?)?(?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => $m['name'], - 'short' => false, - 'literal' => false, - 'required' => true, - 'positional' => false, - 'hasValue' => !empty($m['hasValue']), - ); - } - /* - * Optional long flag - * [--param] - */ - elseif (preg_match( - '/\G\[ *?--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+) *?\](?: +|$)/s', $def, $m, 0, $pos - )) { - $item = array( - 'name' => $m['name'], - 'short' => false, - 'literal' => false, - 'required' => false, - 'positional' => false, - 'hasValue' => false, - ); - } - /* - * Optional long param - * [--param=] - * [--param=whatever] - */ - elseif (preg_match( - '/\G\[ *?--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+)(?P=\S*?)? *?\](?: +|$)/s', $def, $m, 0, $pos - )) { - $item = array( - 'name' => $m['name'], - 'short' => false, - 'literal' => false, - 'required' => false, - 'positional' => false, - 'hasValue' => !empty($m['hasValue']), - ); - } - /* - * Mandatory short param - * -a - * -a=i - * -a=s - * -a=w - */ - elseif (preg_match('/\G-(?P[a-zA-Z0-9])(?:=(?P[ns]))?(?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => $m['name'], - 'short' => true, - 'literal' => false, - 'required' => true, - 'positional' => false, - 'hasValue' => !empty($m['type']) ? $m['type'] : null, - ); - } - /* - * Optional short param - * [-a] - * [-a=n] - * [-a=s] - */ - elseif (preg_match('/\G\[ *?-(?P[a-zA-Z0-9])(?:=(?P[ns]))? *?\](?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => $m['name'], - 'short' => true, - 'literal' => false, - 'required' => false, - 'positional' => false, - 'hasValue' => !empty($m['type']) ? $m['type'] : null, - ); - } - /* - * Optional literal param alternative - * [ something | somethingElse | anotherOne ] - * [ something | somethingElse | anotherOne ]:namedGroup - */ - elseif (preg_match('/ - \G - \[ - (?P - (?: - \ *? - (?P[a-z0-9][a-zA-Z0-9_\-]*?) - \ *? - (?:\||(?=\])) - \ *? - )+ - ) - \] - (?:\:(?P[a-zA-Z0-9]+))? - (?:\ +|$) - /sx', $def, $m, 0, $pos - ) - ) { - // extract available options - $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); - - // remove dupes - array_unique($options); - - // prepare item - $item = array( - 'name' => isset($m['groupName']) ? $m['groupName'] : 'unnamedGroup' . $unnamedGroupCounter++, - 'literal' => true, - 'required' => false, - 'positional' => true, - 'alternatives' => $options, - 'hasValue' => false, - ); - } - - /* - * Required literal param alternative - * ( something | somethingElse | anotherOne ) - * ( something | somethingElse | anotherOne ):namedGroup - */ - elseif (preg_match('/ - \G - \( - (?P - (?: - \ *? - (?P[a-z0-9][a-zA-Z0-9_\-]+) - \ *? - (?:\||(?=\))) - \ *? - )+ - ) - \) - (?:\:(?P[a-zA-Z0-9]+))? - (?:\ +|$) - /sx', $def, $m, 0, $pos - )) { - // extract available options - $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); - - // remove dupes - array_unique($options); - - // prepare item - $item = array( - 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, - 'literal' => true, - 'required' => true, - 'positional' => true, - 'alternatives' => $options, - 'hasValue' => false, - ); - } - /* - * Required long/short flag alternative - * ( --something | --somethingElse | --anotherOne | -s | -a ) - * ( --something | --somethingElse | --anotherOne | -s | -a ):namedGroup - */ - elseif (preg_match('/ - \G - \( - (?P - (?: - \ *? - \-+(?P[a-zA-Z0-9][a-zA-Z0-9_\-]*?) - \ *? - (?:\||(?=\))) - \ *? - )+ - ) - \) - (?:\:(?P[a-zA-Z0-9]+))? - (?:\ +|$) - /sx', $def, $m, 0, $pos - )) { - // extract available options - $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); - - // remove dupes - array_unique($options); - - // remove prefix - array_walk($options, function (&$val, $key) { - $val = ltrim($val, '-'); - }); - - // prepare item - $item = array( - 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, - 'literal' => false, - 'required' => true, - 'positional' => false, - 'alternatives' => $options, - 'hasValue' => false, - ); - } - /* - * Optional flag alternative - * [ --something | --somethingElse | --anotherOne | -s | -a ] - * [ --something | --somethingElse | --anotherOne | -s | -a ]:namedGroup - */ - elseif (preg_match('/ - \G - \[ - (?P - (?: - \ *? - \-+(?P[a-zA-Z0-9][a-zA-Z0-9_\-]*?) - \ *? - (?:\||(?=\])) - \ *? - )+ - ) - \] - (?:\:(?P[a-zA-Z0-9]+))? - (?:\ +|$) - /sx', $def, $m, 0, $pos - )) { - // extract available options - $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); - - // remove dupes - array_unique($options); - - // remove prefix - array_walk($options, function (&$val, $key) { - $val = ltrim($val, '-'); - }); - - // prepare item - $item = array( - 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, - 'literal' => false, - 'required' => false, - 'positional' => false, - 'alternatives' => $options, - 'hasValue' => false, - ); - } - /* - * Optional literal param, i.e. - * [something] - */ - elseif (preg_match('/\G\[ *?(?P[a-z0-9][a-zA-Z0-9\_\-]*?) *?\](?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => $m['name'], - 'literal' => true, - 'required' => false, - 'positional' => true, - 'hasValue' => false, - ); - } - /* - * Optional value param, i.e. - * [SOMETHING] - */ - elseif (preg_match('/\G\[(?P[a-z0-9][a-zA-Z0-9\_\-]*?)\](?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => strtolower($m['name']), - 'literal' => false, - 'required' => false, - 'positional' => true, - 'hasValue' => true, - ); - } - /* - * Optional value param, syntax 2, i.e. - * [] - */ - elseif (preg_match('/\G\[ *\<(?P[a-z0-9][a-zA-Z0-9\_\-]*?)\> *\](?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => strtolower($m['name']), - 'literal' => false, - 'required' => false, - 'positional' => true, - 'hasValue' => true, - ); - } - /* - * Mandatory value param, i.e. - * - */ - elseif (preg_match('/\G\< *(?P[a-z0-9][a-zA-Z0-9\_\-]*?) *\>(?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => $m['name'], - 'literal' => false, - 'required' => true, - 'positional' => true, - 'hasValue' => true, - ); - } - /* - * Mandatory value param, i.e. - * SOMETHING - */ - elseif (preg_match('/\G(?P[A-Z][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => strtolower($m['name']), - 'literal' => false, - 'required' => true, - 'positional' => true, - 'hasValue' => true, - ); - } - /* - * Mandatory literal param, i.e. - * something - */ - elseif (preg_match('/\G(?P[a-z0-9][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { - $item = array( - 'name' => $m['name'], - 'literal' => true, - 'required' => true, - 'positional' => true, - 'hasValue' => false, - ); - } else { - throw new Exception\InvalidArgumentException( - 'Cannot understand Console route at "' . substr($def, $pos) . '"' - ); - } - - $pos += strlen($m[0]); - $parts[] = $item; - } - - return $parts; - } - - /** - * Returns list of names representing single parameter - * - * @param string $name - * @return string - */ - private function getAliases($name) - { - $namesToMatch = array($name); - foreach ($this->aliases as $alias => $canonical) { - if ($name == $canonical) { - $namesToMatch[] = $alias; - } - } - return $namesToMatch; - } - - /** - * Returns canonical name of a parameter - * - * @param string $name - * @return string - */ - private function getCanonicalName($name) - { - if (isset($this->aliases[$name])) { - return $this->aliases[$name]; - } - return $name; - } - - /** - * Match parameters against route passed to constructor - * - * @param array $params - * @return array|null - */ - public function match($params) - { - $matches = array(); - - /* - * Extract positional and named parts - */ - $positional = $named = array(); - foreach ($this->parts as &$part) { - if ($part['positional']) { - $positional[] = &$part; - } else { - $named[] = &$part; - } - } - - /* - * Scan for named parts inside Console params - */ - foreach ($named as &$part) { - /* - * Prepare match regex - */ - if (isset($part['alternatives'])) { - // an alternative of flags - $regex = '/^\-+(?P'; - - $alternativeAliases = array(); - foreach ($part['alternatives'] as $alternative) { - $alternativeAliases[] = '(?:' . implode('|', $this->getAliases($alternative)) . ')'; - } - - $regex .= join('|', $alternativeAliases); - - if ($part['hasValue']) { - $regex .= ')(?:\=(?P.*?)$)?$/'; - } else { - $regex .= ')$/i'; - } - } else { - // a single named flag - $name = '(?:' . implode('|', $this->getAliases($part['name'])) . ')'; - - if ($part['short'] === true) { - // short variant - if ($part['hasValue']) { - $regex = '/^\-' . $name . '(?:\=(?P.*?)$)?$/i'; - } else { - $regex = '/^\-' . $name . '$/i'; - } - } elseif ($part['short'] === false) { - // long variant - if ($part['hasValue']) { - $regex = '/^\-{2,}' . $name . '(?:\=(?P.*?)$)?$/i'; - } else { - $regex = '/^\-{2,}' . $name . '$/i'; - } - } - } - - /* - * Look for param - */ - $value = $param = null; - for ($x = 0, $count = count($params); $x < $count; $x++) { - if (preg_match($regex, $params[$x], $m)) { - // found param - $param = $params[$x]; - - // prevent further scanning of this param - array_splice($params, $x, 1); - - if (isset($m['value'])) { - $value = $m['value']; - } - - if (isset($m['name'])) { - $matchedName = $this->getCanonicalName($m['name']); - } - - break; - } - } - - - if (!$param) { - /* - * Drop out if that was a mandatory param - */ - if ($part['required']) { - return null; - } - - /* - * Continue to next positional param - */ - else { - continue; - } - } - - - /* - * Value for flags is always boolean - */ - if ($param && !$part['hasValue']) { - $value = true; - } - - /* - * Try to retrieve value if it is expected - */ - if ((null === $value || "" === $value) && $part['hasValue']) { - if ($x < count($params)+1 && isset($params[$x])) { - // retrieve value from adjacent param - $value = $params[$x]; - - // prevent further scanning of this param - array_splice($params, $x, 1); - } else { - // there are no more params available - return null; - } - } - - /* - * Validate the value against constraints - */ - if ($part['hasValue'] && isset($this->constraints[$part['name']])) { - if ( - !preg_match($this->constraints[$part['name']], $value) - ) { - // constraint failed - return null; - } - } - - /* - * Store the value - */ - if ($part['hasValue']) { - $matches[$part['name']] = $value; - } else { - $matches[$part['name']] = true; - } - - /* - * If there are alternatives, fill them - */ - if (isset($part['alternatives'])) { - if ($part['hasValue']) { - foreach ($part['alternatives'] as $alt) { - if ($alt === $matchedName && !isset($matches[$alt])) { - $matches[$alt] = $value; - } elseif (!isset($matches[$alt])) { - $matches[$alt] = null; - } - } - } else { - foreach ($part['alternatives'] as $alt) { - if ($alt === $matchedName && !isset($matches[$alt])) { - $matches[$alt] = isset($this->defaults[$alt])? $this->defaults[$alt] : true; - } elseif (!isset($matches[$alt])) { - $matches[$alt] = false; - } - } - } - } - } - - /* - * Scan for left-out flags that should result in a mismatch - */ - foreach ($params as $param) { - if (preg_match('#^\-+#', $param)) { - return null; // there is an unrecognized flag - } - } - - /* - * Go through all positional params - */ - $argPos = 0; - foreach ($positional as &$part) { - /* - * Check if param exists - */ - if (!isset($params[$argPos])) { - if ($part['required']) { - // cannot find required positional param - return null; - } else { - // stop matching - break; - } - } - - $value = $params[$argPos]; - - /* - * Check if literal param matches - */ - if ($part['literal']) { - if ( - (isset($part['alternatives']) && !in_array($value, $part['alternatives'])) || - (!isset($part['alternatives']) && $value != $part['name']) - ) { - return null; - } - } - - /* - * Validate the value against constraints - */ - if ($part['hasValue'] && isset($this->constraints[$part['name']])) { - if ( - !preg_match($this->constraints[$part['name']], $value) - ) { - // constraint failed - return null; - } - } - - /* - * Store the value - */ - if ($part['hasValue']) { - $matches[$part['name']] = $value; - } elseif (isset($part['alternatives'])) { - // from all alternatives set matching parameter to TRUE and the rest to FALSE - foreach ($part['alternatives'] as $alt) { - if ($alt == $value) { - $matches[$alt] = isset($this->defaults[$alt])? $this->defaults[$alt] : true; - } else { - $matches[$alt] = false; - } - } - - // set alternatives group value - $matches[$part['name']] = $value; - } elseif (!$part['required']) { - // set optional parameter flag - $name = $part['name']; - $matches[$name] = isset($this->defaults[$name])? $this->defaults[$name] : true; - } - - /* - * Advance to next argument - */ - $argPos++; - - } - - /* - * Check if we have consumed all positional parameters - */ - if ($argPos < count($params)) { - return null; // there are extraneous params that were not consumed - } - - /* - * Any optional flags that were not entered have value false - */ - foreach ($this->parts as &$part) { - if (!$part['required'] && !$part['hasValue']) { - if (!isset($matches[$part['name']])) { - $matches[$part['name']] = false; - } - // unset alternatives also should be false - if (isset($part['alternatives'])) { - foreach ($part['alternatives'] as $alt) { - if (!isset($matches[$alt])) { - $matches[$alt] = false; - } - } - } - } - } - - // run filters - foreach ($matches as $name => $value) { - if (isset($this->filters[$name])) { - $matches[$name] = $this->filters[$name]->filter($value); - } - } - - // run validators - $valid = true; - foreach ($matches as $name => $value) { - if (isset($this->validators[$name])) { - $valid &= $this->validators[$name]->isValid($value); - } - } - - if (!$valid) { - return null; - } - - return array_replace($this->defaults, $matches); - } -} diff --git a/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php b/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php deleted file mode 100644 index e1656769ccd..00000000000 --- a/library/Zend/Console/RouteMatcher/RouteMatcherInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -=5.3.3" }, - "require-dev": { - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-stdlib": "self.version" - }, "suggest": { - "zendframework/zend-eventmanager": "Zend\\EventManager component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-stdlib": "Zend\\Stdlib component" + "zendframework/zend-stdlib": "self.version" }, "extra": { "branch-alias": { diff --git a/library/Zend/Di/composer.json b/library/Zend/Di/composer.json index 46607450a88..a767b4ce4ea 100644 --- a/library/Zend/Di/composer.json +++ b/library/Zend/Di/composer.json @@ -17,12 +17,6 @@ "zendframework/zend-code": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-servicemanager": "self.version" - }, - "suggest": { - "zendframework/zend-servicemanager": "Zend\\ServiceManager component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/EventManager/ProvidesEvents.php b/library/Zend/EventManager/ProvidesEvents.php index 107d64d7b8b..ea46333a1f4 100644 --- a/library/Zend/EventManager/ProvidesEvents.php +++ b/library/Zend/EventManager/ProvidesEvents.php @@ -43,9 +43,6 @@ public function setEventManager(EventManagerInterface $events) } $events->setIdentifiers($identifiers); $this->events = $events; - if (method_exists($this, 'attachDefaultListeners')) { - $this->attachDefaultListeners(); - } return $this; } diff --git a/library/Zend/Feed/composer.json b/library/Zend/Feed/composer.json index 3a3bad5b76a..d55068f011f 100644 --- a/library/Zend/Feed/composer.json +++ b/library/Zend/Feed/composer.json @@ -17,16 +17,7 @@ "zendframework/zend-escaper": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-db": "self.version", - "zendframework/zend-cache": "self.version", - "zendframework/zend-http": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-validator": "self.version" - }, "suggest": { - "zendframework/zend-cache": "Zend\\Cache component", - "zendframework/zend-db": "Zend\\Db component", "zendframework/zend-http": "Zend\\Http for PubSubHubbub, and optionally for use with Zend\\Feed\\Reader", "zendframework/zend-servicemanager": "Zend\\ServiceManager component, for default/recommended ExtensionManager implementations", "zendframework/zend-validator": "Zend\\Validator component" diff --git a/library/Zend/File/composer.json b/library/Zend/File/composer.json index 66edce11a21..c32a985a6da 100644 --- a/library/Zend/File/composer.json +++ b/library/Zend/File/composer.json @@ -16,16 +16,6 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-filter": "self.version", - "zendframework/zend-i18n": "self.version", - "zendframework/zend-validator": "self.version" - }, - "suggest": { - "zendframework/zend-filter": "Zend\\Filter component", - "zendframework/zend-i18n": "Zend\\I18n component", - "zendframework/zend-validator": "Zend\\Validator component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Filter/FilterPluginManager.php b/library/Zend/Filter/FilterPluginManager.php index 9fea2321bc5..0f07483f8fa 100644 --- a/library/Zend/Filter/FilterPluginManager.php +++ b/library/Zend/Filter/FilterPluginManager.php @@ -58,7 +58,6 @@ class FilterPluginManager extends AbstractPluginManager 'int' => 'Zend\Filter\Int', 'null' => 'Zend\Filter\Null', 'numberformat' => 'Zend\I18n\Filter\NumberFormat', - 'numberparse' => 'Zend\I18n\Filter\NumberParse', 'pregreplace' => 'Zend\Filter\PregReplace', 'realpath' => 'Zend\Filter\RealPath', 'stringtolower' => 'Zend\Filter\StringToLower', diff --git a/library/Zend/Filter/composer.json b/library/Zend/Filter/composer.json index 5433d58a92a..a069522019f 100644 --- a/library/Zend/Filter/composer.json +++ b/library/Zend/Filter/composer.json @@ -17,16 +17,14 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-crypt": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-uri": "self.version" + "zendframework/zend-crypt": "self.version" }, "suggest": { - "zendframework/zend-crypt": "Zend\\Crypt component", "zendframework/zend-i18n": "Zend\\I18n component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-stdlib": "Zend\\Stdlib component", - "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter" + "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter", + "zendframework/zend-validator": "Zend\\Validator component", + "zendframework/zend-crypt": "Zend\\Crypt component", + "zendframework/zend-stdlib": "Zend\\Stdlib component" }, "extra": { "branch-alias": { diff --git a/library/Zend/Form/Element.php b/library/Zend/Form/Element.php index 8ce4aa89fee..858e9caa468 100644 --- a/library/Zend/Form/Element.php +++ b/library/Zend/Form/Element.php @@ -16,8 +16,7 @@ class Element implements ElementAttributeRemovalInterface, ElementInterface, - InitializableInterface, - LabelOptionsAwareInterface + InitializableInterface { /** * @var array @@ -34,15 +33,6 @@ class Element implements */ protected $labelAttributes; - /** - * Label specific options - * - * @var array - */ - protected $labelOptions = array( - 'disable_html_escape' => false - ); - /** * @var array Validation error messages */ @@ -133,10 +123,6 @@ public function setOptions($options) $this->setLabelAttributes($options['label_attributes']); } - if (isset($options['label_options'])) { - $this->setLabelOptions($options['label_options']); - } - $this->options = $options; return $this; @@ -351,28 +337,6 @@ public function getLabelAttributes() return $this->labelAttributes; } - /** - * Set label specific options - * - * @param array $labelOptions - * @return Element|ElementInterface - */ - public function setLabelOptions(array $labelOptions) - { - $this->labelOptions = $labelOptions; - return $this; - } - - /** - * Get label specific options - * - * @return array - */ - public function getLabelOptions() - { - return $this->labelOptions; - } - /** * Set a list of messages to report when validation fails * diff --git a/library/Zend/Form/Element/Checkbox.php b/library/Zend/Form/Element/Checkbox.php index 8b3e6172ac5..87447ad01d2 100644 --- a/library/Zend/Form/Element/Checkbox.php +++ b/library/Zend/Form/Element/Checkbox.php @@ -167,14 +167,11 @@ public function getInputSpecification() $spec = array( 'name' => $this->getName(), 'required' => true, + 'validators' => array( + $this->getValidator() + ) ); - if ($validator = $this->getValidator()) { - $spec['validators'] = array( - $validator, - ); - } - return $spec; } diff --git a/library/Zend/Form/Element/DateSelect.php b/library/Zend/Form/Element/DateSelect.php index ace449aab32..ccee6878335 100644 --- a/library/Zend/Form/Element/DateSelect.php +++ b/library/Zend/Form/Element/DateSelect.php @@ -114,18 +114,6 @@ public function setValue($value) $this->dayElement->setValue($value['day']); } - /** - * @return String - */ - public function getValue() - { - return sprintf('%s-%s-%s', - $this->getYearElement()->getValue(), - $this->getMonthElement()->getValue(), - $this->getDayElement()->getValue() - ); - } - /** * Prepare the form element (mostly used for rendering purposes) * diff --git a/library/Zend/Form/Element/DateTimeSelect.php b/library/Zend/Form/Element/DateTimeSelect.php index 5e6f0e3db09..43c47910d96 100644 --- a/library/Zend/Form/Element/DateTimeSelect.php +++ b/library/Zend/Form/Element/DateTimeSelect.php @@ -243,21 +243,6 @@ public function setValue($value) $this->secondElement->setValue($value['second']); } - /** - * @return String - */ - public function getValue() - { - return sprintf('%s-%s-%s %s:%s:%s', - $this->getYearElement()->getValue(), - $this->getMonthElement()->getValue(), - $this->getDayElement()->getValue(), - $this->getHourElement()->getValue(), - $this->getMinuteElement()->getValue(), - $this->getSecondElement()->getValue() - ); - } - /** * Prepare the form element (mostly used for rendering purposes) * diff --git a/library/Zend/Form/Element/MonthSelect.php b/library/Zend/Form/Element/MonthSelect.php index 8c9689335f6..6ff76b59cca 100644 --- a/library/Zend/Form/Element/MonthSelect.php +++ b/library/Zend/Form/Element/MonthSelect.php @@ -276,17 +276,6 @@ public function setValue($value) $this->monthElement->setValue($value['month']); } - /** - * @return String - */ - public function getValue() - { - return sprintf('%s-%s', - $this->getYearElement()->getValue(), - $this->getMonthElement()->getValue() - ); - } - /** * Prepare the form element (mostly used for rendering purposes) * diff --git a/library/Zend/Form/Element/MultiCheckbox.php b/library/Zend/Form/Element/MultiCheckbox.php index 48fe7b62513..40bb8a847ef 100644 --- a/library/Zend/Form/Element/MultiCheckbox.php +++ b/library/Zend/Form/Element/MultiCheckbox.php @@ -26,11 +26,6 @@ class MultiCheckbox extends Checkbox 'type' => 'multi_checkbox', ); - /** - * @var bool - */ - protected $disableInArrayValidator = false; - /** * @var bool */ @@ -92,9 +87,6 @@ public function setOptions($options) if (isset($this->options['options'])) { $this->setValueOptions($this->options['options']); } - if (isset($this->options['disable_inarray_validator'])) { - $this->setDisableInArrayValidator($this->options['disable_inarray_validator']); - } return $this; } @@ -117,28 +109,6 @@ public function setAttribute($key, $value) return parent::setAttribute($key, $value); } - /** - * Set the flag to allow for disabling the automatic addition of an InArray validator. - * - * @param bool $disableOption - * @return Select - */ - public function setDisableInArrayValidator($disableOption) - { - $this->disableInArrayValidator = (bool) $disableOption; - return $this; - } - - /** - * Get the disable in array validator flag. - * - * @return bool - */ - public function disableInArrayValidator() - { - return $this->disableInArrayValidator; - } - /** * Get validator * @@ -146,7 +116,7 @@ public function disableInArrayValidator() */ protected function getValidator() { - if (null === $this->validator && !$this->disableInArrayValidator()) { + if (null === $this->validator) { $inArrayValidator = new InArrayValidator(array( 'haystack' => $this->getValueOptionsValues(), 'strict' => false, diff --git a/library/Zend/Form/FormElementManager.php b/library/Zend/Form/FormElementManager.php index 679c89b3442..fc7561f7b12 100644 --- a/library/Zend/Form/FormElementManager.php +++ b/library/Zend/Form/FormElementManager.php @@ -123,62 +123,4 @@ public function validatePlugin($plugin) (is_object($plugin) ? get_class($plugin) : gettype($plugin)) )); } - - /** - * Retrieve a service from the manager by name - * - * Allows passing an array of options to use when creating the instance. - * createFromInvokable() will use these and pass them to the instance - * constructor if not null and a non-empty array. - * - * @param string $name - * @param string|array $options - * @param bool $usePeeringServiceManagers - * @return object - */ - public function get($name, $options = array(), $usePeeringServiceManagers = true) - { - if (is_string($options)) { - $options = array('name' => $options); - } - return parent::get($name, $options, $usePeeringServiceManagers); - } - - /** - * Attempt to create an instance via an invokable class - * - * Overrides parent implementation by passing $creationOptions to the - * constructor, if non-null. - * - * @param string $canonicalName - * @param string $requestedName - * @return null|\stdClass - * @throws Exception\ServiceNotCreatedException If resolved class does not exist - */ - protected function createFromInvokable($canonicalName, $requestedName) - { - $invokable = $this->invokableClasses[$canonicalName]; - - if (null === $this->creationOptions - || (is_array($this->creationOptions) && empty($this->creationOptions)) - ) { - $instance = new $invokable(); - } else { - if (isset($this->creationOptions['name'])) { - $name = $this->creationOptions['name']; - } else { - $name = $requestedName; - } - - if (isset($this->creationOptions['options'])) { - $options = $this->creationOptions['options']; - } else { - $options = $this->creationOptions; - } - - $instance = new $invokable($name, $options); - } - - return $instance; - } } diff --git a/library/Zend/Form/LabelOptionsAwareInterface.php b/library/Zend/Form/LabelOptionsAwareInterface.php deleted file mode 100644 index 54a92952b2d..00000000000 --- a/library/Zend/Form/LabelOptionsAwareInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - false - ); - - /** - * Set the attributes to use with the label - * - * @param array $labelAttributes - * @return LabelOptionsAwareInterface - */ - public function setLabelAttributes(array $labelAttributes) - { - $this->labelAttributes = $labelAttributes; - return $this; - } - - /** - * Get the attributes to use with the label - * - * @return array - */ - public function getLabelAttributes() - { - return $this->labelAttributes; - } - - /** - * Set label specific options - * - * @param array $labelOptions - * @return LabelOptionsAwareInterface - */ - public function setLabelOptions(array $labelOptions) - { - $this->labelOptions = $labelOptions; - return $this; - } - - /** - * Get label specific options - * - * @return array - */ - public function getLabelOptions() - { - return $this->labelOptions; - } -} diff --git a/library/Zend/Form/View/Helper/FormLabel.php b/library/Zend/Form/View/Helper/FormLabel.php index c23949380bd..384d180ee66 100644 --- a/library/Zend/Form/View/Helper/FormLabel.php +++ b/library/Zend/Form/View/Helper/FormLabel.php @@ -11,7 +11,6 @@ use Zend\Form\ElementInterface; use Zend\Form\Exception; -use Zend\Form\LabelOptionsAwareInterface; class FormLabel extends AbstractHelper { @@ -119,11 +118,7 @@ public function openTag($attributesOrElement = null) )); } - $labelAttributes = array(); - if ($attributesOrElement instanceof LabelOptionsAwareInterface) { - $labelAttributes = $attributesOrElement->getLabelAttributes(); - } - + $labelAttributes = $attributesOrElement->getLabelAttributes(); $attributes = array('for' => $id); if (!empty($labelAttributes)) { diff --git a/library/Zend/Form/View/Helper/FormRow.php b/library/Zend/Form/View/Helper/FormRow.php index f0fcbc21a0c..a4e358c9c78 100644 --- a/library/Zend/Form/View/Helper/FormRow.php +++ b/library/Zend/Form/View/Helper/FormRow.php @@ -12,7 +12,6 @@ use Zend\Form\Element\Button; use Zend\Form\ElementInterface; use Zend\Form\Exception; -use Zend\Form\LabelOptionsAwareInterface; use Zend\Form\View\Helper\AbstractHelper; class FormRow extends AbstractHelper @@ -161,18 +160,8 @@ public function render(ElementInterface $element) $elementString = $elementHelper->render($element); if (isset($label) && '' !== $label) { - - $labelOptions = array(); - $labelAttributes = array(); - - if ($element instanceof LabelOptionsAwareInterface) { - $labelOptions = $element->getLabelOptions(); - $labelAttributes = $element->getLabelAttributes(); - } - - if (empty($labelOptions) || $labelOptions['disable_html_escape'] == false) { - $label = $escapeHtmlHelper($label); - } + $label = $escapeHtmlHelper($label); + $labelAttributes = $element->getLabelAttributes(); if (empty($labelAttributes)) { $labelAttributes = $this->labelAttributes; diff --git a/library/Zend/Form/composer.json b/library/Zend/Form/composer.json index cb82654f8a2..0c8e5a7f4b7 100644 --- a/library/Zend/Form/composer.json +++ b/library/Zend/Form/composer.json @@ -18,26 +18,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-captcha": "self.version", - "zendframework/zend-code": "self.version", - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-i18n": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-validator": "self.version", - "zendframework/zend-view": "self.version", "zendframework/zendservice-recaptcha": "*" }, "suggest": { - - "zendframework/zend-captcha": "Zend\\Captcha component", - "zendframework/zend-code": "Zend\\Code component", - "zendframework/zend-eventmanager": "Zend\\EventManager component", - "zendframework/zend-filter": "Zend\\Filter component", - "zendframework/zend-i18n": "Zend\\I18n component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-validator": "Zend\\Validator component", - "zendframework/zend-view": "Zend\\View component", "zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha component" }, "extra": { diff --git a/library/Zend/Http/Header/ContentType.php b/library/Zend/Http/Header/ContentType.php index 723bc2a48a8..33eb39dcb78 100644 --- a/library/Zend/Http/Header/ContentType.php +++ b/library/Zend/Http/Header/ContentType.php @@ -9,30 +9,13 @@ namespace Zend\Http\Header; -use stdClass; - /** * @throws Exception\InvalidArgumentException * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 */ class ContentType implements HeaderInterface { - /** - * @var string - */ - protected $mediaType; - - /** - * @var array - */ - protected $parameters = array(); - /** - * Factory method: create an object from a string representation - * - * @param string $headerLine - * @return self - */ public static function fromString($headerLine) { $header = new static(); @@ -44,335 +27,24 @@ public static function fromString($headerLine) throw new Exception\InvalidArgumentException('Invalid header line for Content-Type string: "' . $name . '"'); } - $header->value = $value; - $parts = explode(';', $value); - $mediaType = array_shift($parts); - $header->mediaType = trim($mediaType); - - if (count($parts) > 0) { - $parameters = array(); - foreach ($parts as $parameter) { - $parameter = trim($parameter); - if (!preg_match('/^(?P[^\s\=]+)\=(?P[^\s\=]*)$/', $parameter, $matches)) { - continue; - } - $parameters[$matches['key']] = $matches['value']; - } - $header->setParameters($parameters); - } + // @todo implementation details + $header->value = $value; return $header; } - /** - * Determine if the mediatype value in this header matches the provided criteria - * - * @param array|string $matchAgainst - * @return string|bool Matched value or false - */ - public function match($matchAgainst) - { - if (is_string($matchAgainst)) { - $matchAgainst = $this->splitMediaTypesFromString($matchAgainst); - } - - $mediaType = $this->getMediaType(); - $left = $this->getMediaTypeObjectFromString($mediaType); - - foreach ($matchAgainst as $matchType) { - $matchType = strtolower($matchType); - - if ($mediaType == $matchType) { - return $matchType; - } - - $right = $this->getMediaTypeObjectFromString($matchType); - - // Is the right side a wildcard type? - if ($right->type == '*') { - if ($this->validateSubtype($right, $left)) { - return $matchType; - } - } - - // Do the types match? - if ($right->type == $left->type) { - if ($this->validateSubtype($right, $left)) { - return $matchType; - } - } - } - - return false; - } - - /** - * Create a string representation of the header - * - * @return string - */ - public function toString() - { - return 'Content-Type: ' . $this->getFieldValue(); - } - - /** - * Get the field name - * - * @return string - */ public function getFieldName() { return 'Content-Type'; } - /** - * Get the field value - * - * @return string - */ public function getFieldValue() { - if (null !== $this->value) { - return $this->value; - } - return $this->assembleValue(); + return $this->value; } - /** - * Set the media type - * - * @param string $mediaType - * @return self - */ - public function setMediaType($mediaType) - { - $this->mediaType = strtolower($mediaType); - $this->value = null; - return $this; - } - - /** - * Get the media type - * - * @return string - */ - public function getMediaType() - { - return $this->mediaType; - } - - /** - * Set additional content-type parameters - * - * @param array $parameters - * @return self - */ - public function setParameters(array $parameters) - { - $this->parameters = array_merge($this->parameters, $parameters); - $this->value = null; - return $this; - } - - /** - * Get any additional content-type parameters currently set - * - * @return array - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * Set the content-type character set encoding - * - * @param string $charset - * @return self - */ - public function setCharset($charset) - { - $this->parameters['charset'] = $charset; - $this->value = null; - return $this; - } - - /** - * Get the content-type character set encoding, if any - * - * @return null|string - */ - public function getCharset() - { - if (isset($this->parameters['charset'])) { - return $this->parameters['charset']; - } - return null; - } - - /** - * Assemble the value based on the media type and any available parameters - * - * @return string - */ - protected function assembleValue() - { - $mediaType = $this->getMediaType(); - if (empty($this->parameters)) { - return $mediaType; - } - - $parameters = array(); - foreach ($this->parameters as $key => $value) { - $parameters[] = sprintf('%s=%s', $key, $value); - } - - return sprintf('%s; %s', $mediaType, implode('; ', $parameters)); - } - - /** - * Split comma-separated media types into an array - * - * @param string $criteria - * @return array - */ - protected function splitMediaTypesFromString($criteria) - { - $mediaTypes = explode(',', $criteria); - array_walk($mediaTypes, 'trim'); - return $mediaTypes; - } - - /** - * Split a mediatype string into an object with the following parts: - * - * - type - * - subtype - * - format - * - * @param string $string - * @return stdClass - */ - protected function getMediaTypeObjectFromString($string) - { - if (!is_string($string)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Non-string mediatype "%s" provided', - (is_object($string) ? get_class($string) : gettype($string)) - )); - } - - $parts = explode('/', $string, 2); - if (1 == count($parts)) { - throw new Exception\DomainException(sprintf( - 'Invalid mediatype "%s" provided', - $string - )); - } - - $type = array_shift($parts); - $subtype = array_shift($parts); - $format = $subtype; - if (strstr($subtype, '+')) { - $parts = explode('+', $subtype, 2); - $subtype = array_shift($parts); - $format = array_shift($parts); - } - - $mediaType = (object) array( - 'type' => $type, - 'subtype' => $subtype, - 'format' => $format, - ); - - return $mediaType; - } - - /** - * Validate a subtype - * - * @param stdClass $right - * @param stdClass $left - * @return bool - */ - protected function validateSubtype($right, $left) - { - // Is the right side a wildcard subtype? - if ($right->subtype == '*') { - return $this->validateFormat($right, $left); - } - - // Do the right side and left side subtypes match? - if ($right->subtype == $left->subtype) { - return $this->validateFormat($right, $left); - } - - // Is the right side a partial wildcard? - if ('*' == substr($right->subtype, -1)) { - // validate partial-wildcard subtype - if (!$this->validatePartialWildcard($right->subtype, $left->subtype)) { - return false; - } - // Finally, verify format is valid - return $this->validateFormat($right, $left); - } - - // Does the right side subtype match the left side format? - if ($right->subtype == $left->format) { - return true; - } - - // At this point, there is no valid match - return false; - } - - /** - * Validate the format - * - * Validate that the right side format matches what the left side defines. - * - * @param string $right - * @param string $left - * @return bool - */ - protected function validateFormat($right, $left) - { - if ($right->format && $left->format) { - if ($right->format == '*') { - return true; - } - if ($right->format == $left->format) { - return true; - } - return false; - } - - return true; - } - - /** - * Validate a partial wildcard (i.e., string ending in '*') - * - * @param string $right - * @param string $left - * @return bool - */ - protected function validatePartialWildcard($right, $left) + public function toString() { - $requiredSegment = substr($right, 0, strlen($right) - 1); - if ($requiredSegment == $left) { - return true; - } - - if (strlen($requiredSegment) >= strlen($left)) { - return false; - } - - if (0 === strpos($left, $requiredSegment)) { - return true; - } - - return false; + return 'Content-Type: ' . $this->getFieldValue(); } } diff --git a/library/Zend/Http/Header/Exception/DomainException.php b/library/Zend/Http/Header/Exception/DomainException.php deleted file mode 100644 index 959f8cccd12..00000000000 --- a/library/Zend/Http/Header/Exception/DomainException.php +++ /dev/null @@ -1,14 +0,0 @@ - null, + 'style' => NumberFormatter::DEFAULT_STYLE, + 'type' => NumberFormatter::TYPE_DOUBLE + ); + + /** + * @var NumberFormatter + */ + protected $formatter = null; + + /** + * @param array|Traversable|string|null $localeOrOptions + * @param int $style + * @param int $type + */ + public function __construct( + $localeOrOptions = null, + $style = NumberFormatter::DEFAULT_STYLE, + $type = NumberFormatter::TYPE_DOUBLE) + { + parent::__construct(); + if ($localeOrOptions !== null) { + if ($localeOrOptions instanceof Traversable) { + $localeOrOptions = iterator_to_array($localeOrOptions); + } + + if (!is_array($localeOrOptions)) { + $this->setLocale($localeOrOptions); + $this->setStyle($style); + $this->setType($type); + } else { + $this->setOptions($localeOrOptions); + } + } + } + + /** + * @param string|null $locale + * @return NumberFormat + */ + public function setLocale($locale = null) + { + $this->options['locale'] = $locale; + $this->formatter = null; + return $this; + } + + /** + * @param int $style + * @return NumberFormat + */ + public function setStyle($style) + { + $this->options['style'] = (int) $style; + $this->formatter = null; + return $this; + } + + /** + * @return int + */ + public function getStyle() + { + return $this->options['style']; + } + + /** + * @param int $type + * @return NumberFormat + */ + public function setType($type) + { + $this->options['type'] = (int) $type; + return $this; + } + + /** + * @return int + */ + public function getType() + { + return $this->options['type']; + } + + /** + * @param NumberFormatter $formatter + * @return NumberFormat + */ + public function setFormatter(NumberFormatter $formatter) + { + $this->formatter = $formatter; + return $this; + } + + /** + * @return NumberFormatter + * @throws Exception\RuntimeException + */ + public function getFormatter() + { + if ($this->formatter === null) { + $formatter = NumberFormatter::create($this->getLocale(), $this->getStyle()); + if (!$formatter) { + throw new Exception\RuntimeException( + 'Can not create NumberFormatter instance; ' . intl_get_error_message() + ); + } + + $this->formatter = $formatter; + } + + return $this->formatter; + } /** * Defined by Zend\Filter\FilterInterface @@ -24,28 +140,24 @@ class NumberFormat extends NumberParse */ public function filter($value) { - if (!is_int($value) - && !is_float($value)) { - - $result = parent::filter($value); + $formatter = $this->getFormatter(); + $type = $this->getType(); + if (is_int($value) || is_float($value)) { + ErrorHandler::start(); + $result = $formatter->format($value, $type); + ErrorHandler::stop(); } else { - + $value = str_replace(array("\xC2\xA0", ' '), '', $value); ErrorHandler::start(); - - $result = $this->getFormatter()->format( - $value, - $this->getType() - ); - + $result = $formatter->parse($value, $type); ErrorHandler::stop(); - } - if (false !== $result) { - return str_replace("\xC2\xA0", ' ', $result); + if ($result === false) { + return $value; } - return $value; + return str_replace("\xC2\xA0", ' ', $result); } } diff --git a/library/Zend/I18n/Filter/NumberParse.php b/library/Zend/I18n/Filter/NumberParse.php deleted file mode 100644 index d919158aebe..00000000000 --- a/library/Zend/I18n/Filter/NumberParse.php +++ /dev/null @@ -1,163 +0,0 @@ - null, - 'style' => NumberFormatter::DEFAULT_STYLE, - 'type' => NumberFormatter::TYPE_DOUBLE - ); - - /** - * @var NumberFormatter - */ - protected $formatter = null; - - /** - * @param array|Traversable|string|null $localeOrOptions - * @param int $style - * @param int $type - */ - public function __construct( - $localeOrOptions = null, - $style = NumberFormatter::DEFAULT_STYLE, - $type = NumberFormatter::TYPE_DOUBLE - ) { - parent::__construct(); - if ($localeOrOptions !== null) { - if ($localeOrOptions instanceof Traversable) { - $localeOrOptions = iterator_to_array($localeOrOptions); - } - - if (!is_array($localeOrOptions)) { - $this->setLocale($localeOrOptions); - $this->setStyle($style); - $this->setType($type); - } else { - $this->setOptions($localeOrOptions); - } - } - } - - /** - * @param string|null $locale - * @return NumberFormat - */ - public function setLocale($locale = null) - { - $this->options['locale'] = $locale; - $this->formatter = null; - return $this; - } - - /** - * @param int $style - * @return NumberFormat - */ - public function setStyle($style) - { - $this->options['style'] = (int) $style; - $this->formatter = null; - return $this; - } - - /** - * @return int - */ - public function getStyle() - { - return $this->options['style']; - } - - /** - * @param int $type - * @return NumberFormat - */ - public function setType($type) - { - $this->options['type'] = (int) $type; - return $this; - } - - /** - * @return int - */ - public function getType() - { - return $this->options['type']; - } - - /** - * @param NumberFormatter $formatter - * @return NumberFormat - */ - public function setFormatter(NumberFormatter $formatter) - { - $this->formatter = $formatter; - return $this; - } - - /** - * @return NumberFormatter - * @throws Exception\RuntimeException - */ - public function getFormatter() - { - if ($this->formatter === null) { - $formatter = NumberFormatter::create($this->getLocale(), $this->getStyle()); - if (!$formatter) { - throw new Exception\RuntimeException( - 'Can not create NumberFormatter instance; ' . intl_get_error_message() - ); - } - - $this->formatter = $formatter; - } - - return $this->formatter; - } - - - /** - * Defined by Zend\Filter\FilterInterface - * - * @see Zend\Filter\FilterInterface::filter() - * @param mixed $value - * @return mixed - */ - public function filter($value) - { - if (!is_int($value) - && !is_float($value) - ) { - ErrorHandler::start(); - - $result = $this->getFormatter()->parse( - $value, - $this->getType() - ); - - ErrorHandler::stop(); - - if (false !== $result) { - return $result; - } - } - - return $value; - } -} diff --git a/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php b/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php deleted file mode 100644 index 19044e298c9..00000000000 --- a/library/Zend/I18n/Translator/Loader/AbstractFileLoader.php +++ /dev/null @@ -1,82 +0,0 @@ -useIncludePath = (bool) $flag; - return $this; - } - - /** - * Are we using the include_path to resolve translation files? - * - * @return bool - */ - public function useIncludePath() - { - return $this->useIncludePath; - } - - /** - * Resolve a translation file - * - * Checks if the file exists and is readable, returning a boolean false if not; if the "useIncludePath" - * flag is enabled, it will attempt to resolve the file from the - * include_path if the file does not exist on the current working path. - * - * @param string $filename - * @return string|false - */ - protected function resolveFile($filename) - { - if (!is_file($filename) || !is_readable($filename)) { - if (!$this->useIncludePath()) { - return false; - } - return $this->resolveViaIncludePath($filename); - } - return $filename; - } - - /** - * Resolve a translation file via the include_path - * - * @param string $filename - * @return string|false - */ - protected function resolveViaIncludePath($filename) - { - $resolvedIncludePath = stream_resolve_include_path($filename); - if (!$resolvedIncludePath || !is_file($resolvedIncludePath) || !is_readable($resolvedIncludePath)) { - return false; - } - return $resolvedIncludePath; - } -} diff --git a/library/Zend/I18n/Translator/Loader/Gettext.php b/library/Zend/I18n/Translator/Loader/Gettext.php index 45d296dbcdd..ca156526680 100644 --- a/library/Zend/I18n/Translator/Loader/Gettext.php +++ b/library/Zend/I18n/Translator/Loader/Gettext.php @@ -17,7 +17,7 @@ /** * Gettext loader. */ -class Gettext extends AbstractFileLoader +class Gettext implements FileLoaderInterface { /** * Current file pointer. @@ -44,10 +44,9 @@ class Gettext extends AbstractFileLoader */ public function load($locale, $filename) { - $resolvedFile = $this->resolveFile($filename); - if (!$resolvedFile) { + if (!is_file($filename) || !is_readable($filename)) { throw new Exception\InvalidArgumentException(sprintf( - 'Could not find or open file %s for reading', + 'Could not open file %s for reading', $filename )); } @@ -55,7 +54,7 @@ public function load($locale, $filename) $textDomain = new TextDomain(); ErrorHandler::start(); - $this->file = fopen($resolvedFile, 'rb'); + $this->file = fopen($filename, 'rb'); $error = ErrorHandler::stop(); if (false === $this->file) { throw new Exception\InvalidArgumentException(sprintf( diff --git a/library/Zend/I18n/Translator/Loader/Ini.php b/library/Zend/I18n/Translator/Loader/Ini.php index 93c337459f5..02a9ecac20e 100644 --- a/library/Zend/I18n/Translator/Loader/Ini.php +++ b/library/Zend/I18n/Translator/Loader/Ini.php @@ -17,7 +17,7 @@ /** * PHP INI format loader. */ -class Ini extends AbstractFileLoader +class Ini implements FileLoaderInterface { /** * load(): defined by FileLoaderInterface. @@ -30,18 +30,16 @@ class Ini extends AbstractFileLoader */ public function load($locale, $filename) { - $resolvedIncludePath = stream_resolve_include_path($filename); - $fromIncludePath = ($resolvedIncludePath !== false) ? $resolvedIncludePath : $filename; - if (!$fromIncludePath || !is_file($fromIncludePath) || !is_readable($fromIncludePath)) { + if (!is_file($filename) || !is_readable($filename)) { throw new Exception\InvalidArgumentException(sprintf( - 'Could not find or open file %s for reading', + 'Could not open file %s for reading', $filename )); } $messages = array(); $iniReader = new IniReader(); - $messagesNamespaced = $iniReader->fromFile($fromIncludePath); + $messagesNamespaced = $iniReader->fromFile($filename); $list = $messagesNamespaced; if (isset($messagesNamespaced['translation'])) { diff --git a/library/Zend/I18n/Translator/Loader/PhpArray.php b/library/Zend/I18n/Translator/Loader/PhpArray.php index e00aa573b1d..f93d92e3aaf 100644 --- a/library/Zend/I18n/Translator/Loader/PhpArray.php +++ b/library/Zend/I18n/Translator/Loader/PhpArray.php @@ -16,7 +16,7 @@ /** * PHP array loader. */ -class PhpArray extends AbstractFileLoader +class PhpArray implements FileLoaderInterface { /** * load(): defined by FileLoaderInterface. @@ -29,16 +29,14 @@ class PhpArray extends AbstractFileLoader */ public function load($locale, $filename) { - $resolvedIncludePath = stream_resolve_include_path($filename); - $fromIncludePath = ($resolvedIncludePath !== false) ? $resolvedIncludePath : $filename; - if (!$fromIncludePath || !is_file($fromIncludePath) || !is_readable($fromIncludePath)) { + if (!is_file($filename) || !is_readable($filename)) { throw new Exception\InvalidArgumentException(sprintf( - 'Could not find or open file %s for reading', + 'Could not open file %s for reading', $filename )); } - $messages = include $fromIncludePath; + $messages = include $filename; if (!is_array($messages)) { throw new Exception\InvalidArgumentException(sprintf( diff --git a/library/Zend/I18n/Translator/LoaderPluginManager.php b/library/Zend/I18n/Translator/LoaderPluginManager.php index 5b911bfb7ed..a2df197be90 100644 --- a/library/Zend/I18n/Translator/LoaderPluginManager.php +++ b/library/Zend/I18n/Translator/LoaderPluginManager.php @@ -18,39 +18,6 @@ * Enforces that loaders retrieved are either instances of * Loader\FileLoaderInterface or Loader\RemoteLoaderInterface. Additionally, * it registers a number of default loaders. - * - * If you are wanting to use the ability to load translation files from the - * include_path, you will need to create a factory to override the defaults - * defined in this class. A simple factory might look like: - * - * - * function ($translators) { - * $adapter = new Gettext(); - * $adapter->setUseIncludePath(true); - * return $adapter; - * } - * - * - * You may need to override the Translator service factory to make this happen - * more easily. That can be done by extending it: - * - * - * use Zend\I18n\Translator\TranslatorServiceFactory; - * // or Zend\Mvc\I18n\TranslatorServiceFactory - * use Zend\ServiceManager\ServiceLocatorInterface; - * - * class MyTranslatorServiceFactory extends TranslatorServiceFactory - * { - * public function createService(ServiceLocatorInterface $services) - * { - * $translator = parent::createService($services); - * $translator->getLoaderPluginManager()->setFactory(...); - * return $translator; - * } - * } - * - * - * You would then specify your custom factory in your service configuration. */ class LoaderPluginManager extends AbstractPluginManager { diff --git a/library/Zend/I18n/composer.json b/library/Zend/I18n/composer.json index 79e6d0c53a3..606194d6b0b 100644 --- a/library/Zend/I18n/composer.json +++ b/library/Zend/I18n/composer.json @@ -16,22 +16,10 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-cache": "self.version", - "zendframework/zend-config": "self.version", - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-validator": "self.version", - "zendframework/zend-view": "self.version" - }, "suggest": { "ext-intl": "Required for most features of Zend\\I18n; included in default builds of PHP", - "zendframework/zend-cache": "Zend\\Cache component", - "zendframework/zend-config": "Zend\\Config component", "zendframework/zend-eventmanager": "You should install this package to use the events in the translator", "zendframework/zend-filter": "You should install this package to use the provided filters", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", "zendframework/zend-validator": "You should install this package to use the provided validators", "zendframework/zend-view": "You should install this package to use the provided view helpers", "zendframework/zend-resources": "Translation resources" diff --git a/library/Zend/InputFilter/ArrayInput.php b/library/Zend/InputFilter/ArrayInput.php index 3c5c4783dd7..5dec0151b1b 100644 --- a/library/Zend/InputFilter/ArrayInput.php +++ b/library/Zend/InputFilter/ArrayInput.php @@ -56,8 +56,8 @@ public function isValid($context = null) foreach ($values as $value) { $result = $validator->isValid($value, $context); if (!$result) { - if ($this->hasFallback()) { - $this->setValue($this->getFallbackValue()); + if ($fallbackValue = $this->getFallbackValue()) { + $this->setValue($fallbackValue); $result = true; } break; diff --git a/library/Zend/InputFilter/Input.php b/library/Zend/InputFilter/Input.php index 7d302e8f2b3..da84df9e174 100644 --- a/library/Zend/InputFilter/Input.php +++ b/library/Zend/InputFilter/Input.php @@ -70,11 +70,6 @@ class Input implements InputInterface, EmptyContextInterface */ protected $fallbackValue; - /** - * @var bool - */ - protected $hasFallback = false; - public function __construct($name = null) { $this->name = $name; @@ -178,7 +173,6 @@ public function setValue($value) public function setFallbackValue($value) { $this->fallbackValue = $value; - $this->hasFallback = true; return $this; } @@ -277,20 +271,6 @@ public function getFallbackValue() return $this->fallbackValue; } - /** - * @return bool - */ - public function hasFallback() - { - return $this->hasFallback; - } - - public function clearFallbackValue() - { - $this->hasFallback = false; - $this->fallbackValue = null; - } - /** * @param InputInterface $input * @return Input @@ -328,8 +308,8 @@ public function isValid($context = null) $validator = $this->getValidatorChain(); $value = $this->getValue(); $result = $validator->isValid($value, $context); - if (!$result && $this->hasFallback()) { - $this->setValue($this->getFallbackValue()); + if (!$result && $fallbackValue = $this->getFallbackValue()) { + $this->setValue($fallbackValue); $result = true; } @@ -345,7 +325,7 @@ public function getMessages() return (array) $this->errorMessage; } - if ($this->hasFallback()) { + if ($this->getFallbackValue()) { return array(); } diff --git a/library/Zend/InputFilter/composer.json b/library/Zend/InputFilter/composer.json index 39c4e6c3831..b82d5f23693 100644 --- a/library/Zend/InputFilter/composer.json +++ b/library/Zend/InputFilter/composer.json @@ -18,9 +18,6 @@ "zendframework/zend-validator": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-servicemanager": "self.version" - }, "suggest": { "zendframework/zend-servicemanager": "To support plugin manager support" }, diff --git a/library/Zend/Json/Encoder.php b/library/Zend/Json/Encoder.php index 1bdeefe773e..190edc635a9 100644 --- a/library/Zend/Json/Encoder.php +++ b/library/Zend/Json/Encoder.php @@ -11,7 +11,6 @@ use Iterator; use IteratorAggregate; -use JsonSerializable; use ReflectionClass; use Zend\Json\Exception\InvalidArgumentException; use Zend\Json\Exception\RecursionException; @@ -67,10 +66,6 @@ public static function encode($value, $cycleCheck = false, $options = array()) { $encoder = new static(($cycleCheck) ? true : false, $options); - if ($value instanceof JsonSerializable) { - $value = $value->jsonSerialize(); - } - return $encoder->_encodeValue($value); } diff --git a/library/Zend/Json/composer.json b/library/Zend/Json/composer.json index a9e947f1bca..b9996f9db22 100644 --- a/library/Zend/Json/composer.json +++ b/library/Zend/Json/composer.json @@ -16,12 +16,7 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-http": "self.version", - "zendframework/zend-server": "self.version" - }, "suggest": { - "zendframework/zend-http": "Zend\\Http component", "zendframework/zend-server": "Zend\\Server component" }, "extra": { diff --git a/library/Zend/Ldap/composer.json b/library/Zend/Ldap/composer.json index 08efea25aea..c1cff48df56 100644 --- a/library/Zend/Ldap/composer.json +++ b/library/Zend/Ldap/composer.json @@ -16,12 +16,6 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-eventmanager": "self.version" - }, - "suggest": { - "zendframework/zend-eventmanager": "Zend\\EventManager component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Loader/composer.json b/library/Zend/Loader/composer.json index fffd5df4157..7844ff4d200 100644 --- a/library/Zend/Loader/composer.json +++ b/library/Zend/Loader/composer.json @@ -15,6 +15,9 @@ "require": { "php": ">=5.3.3" }, + "suggest": { + "zendframework/zend-stdlib": "Zend\\Stdlib component" + }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Log/Filter/Sample.php b/library/Zend/Log/Filter/Sample.php deleted file mode 100644 index ae0c88826e0..00000000000 --- a/library/Zend/Log/Filter/Sample.php +++ /dev/null @@ -1,57 +0,0 @@ -sampleRate = (float) $sampleRate; - } - - /** - * Returns TRUE to accept the message, FALSE to block it. - * - * @param array $event event data - * @return bool Accepted ? - */ - public function filter(array $event) - { - return (mt_rand() / mt_getrandmax()) <= $this->sampleRate; - } -} diff --git a/library/Zend/Log/LoggerAwareInterface.php b/library/Zend/Log/LoggerAwareInterface.php index 028c7f40dd2..f0c720f99c8 100644 --- a/library/Zend/Log/LoggerAwareInterface.php +++ b/library/Zend/Log/LoggerAwareInterface.php @@ -16,19 +16,5 @@ */ interface LoggerAwareInterface { - /** - * Set logger instance - * - * @param LoggerInterface - * @return void - */ public function setLogger(LoggerInterface $logger); - - /** - * Get logger instance. Currently commented out as this would possibly break - * existing implementations. - * - * @return null|LoggerInterface - */ - // public function getLogger(); } diff --git a/library/Zend/Log/LoggerAwareTrait.php b/library/Zend/Log/LoggerAwareTrait.php index 2ed7c00c153..70152481484 100644 --- a/library/Zend/Log/LoggerAwareTrait.php +++ b/library/Zend/Log/LoggerAwareTrait.php @@ -30,14 +30,4 @@ public function setLogger(LoggerInterface $logger) return $this; } - - /** - * Get logger object - * - * @return null|LoggerInterface - */ - public function getLogger() - { - return $this->logger; - } } diff --git a/library/Zend/Log/composer.json b/library/Zend/Log/composer.json index f781cbd77de..962f559d92a 100644 --- a/library/Zend/Log/composer.json +++ b/library/Zend/Log/composer.json @@ -18,21 +18,12 @@ "zendframework/zend-servicemanager": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-console": "self.version", - "zendframework/zend-db": "self.version", - "zendframework/zend-escaper": "self.version", - "zendframework/zend-mail": "self.version", - "zendframework/zend-validator": "self.version" - }, "suggest": { "ext-mongo": "*", - "zendframework/zend-console": "Zend\\Console component", "zendframework/zend-db": "Zend\\Db component", "zendframework/zend-escaper": "Zend\\Escaper component, for use in the XML formatter", "zendframework/zend-mail": "Zend\\Mail component", "zendframework/zend-validator": "Zend\\Validator component" - }, "extra": { "branch-alias": { diff --git a/library/Zend/Mail/composer.json b/library/Zend/Mail/composer.json index 27f2c047ca4..bdb440ce230 100644 --- a/library/Zend/Mail/composer.json +++ b/library/Zend/Mail/composer.json @@ -19,13 +19,9 @@ "zendframework/zend-mime": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-validator": "self.version" - }, "suggest": { - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-validator": "Zend\\Validator component" + "zendframework/zend-validator": "Zend\\Validator component", + "zendframework/zend-servicemanager": "Zend\\ServiceManager component" }, "extra": { "branch-alias": { diff --git a/library/Zend/Math/Rand.php b/library/Zend/Math/Rand.php index 2c03d992871..616aa5b7af6 100644 --- a/library/Zend/Math/Rand.php +++ b/library/Zend/Math/Rand.php @@ -34,8 +34,6 @@ abstract class Rand */ public static function getBytes($length, $strong = false) { - $length = (int) $length; - if ($length <= 0) { return false; } diff --git a/library/Zend/Math/composer.json b/library/Zend/Math/composer.json index 793b7efedbf..4af222154dd 100644 --- a/library/Zend/Math/composer.json +++ b/library/Zend/Math/composer.json @@ -15,15 +15,8 @@ "require": { "php": ">=5.3.3" }, - "require-dev": { - "ircmaxell/random-lib": "*", - "ircmaxell/security-lib": "*", - "zendframework/zend-servicemanager": "self.version" - }, "suggest": { - "ircmaxell/random-lib": "Fallback random byte generator for Zend\\Math\\Rand if OpenSSL/Mcrypt extensions are unavailable", - "ircmaxell/security-lib": "SecurityLib component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component" + "ircmaxell/random-lib": "Fallback random byte generator for Zend\\Math\\Rand if OpenSSL/Mcrypt extensions are unavailable" }, "extra": { "branch-alias": { diff --git a/library/Zend/Memory/composer.json b/library/Zend/Memory/composer.json index f592d1b373b..cdf7e825a61 100644 --- a/library/Zend/Memory/composer.json +++ b/library/Zend/Memory/composer.json @@ -15,12 +15,6 @@ "require": { "php": ">=5.3.3" }, - "require-dev": { - "zendframework/zend-cache": "self.version" - }, - "suggest": { - "zendframework/zend-cache": "Zend\\Cache component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Mime/composer.json b/library/Zend/Mime/composer.json index 44534e6d5a1..b7d0c15379c 100644 --- a/library/Zend/Mime/composer.json +++ b/library/Zend/Mime/composer.json @@ -16,12 +16,6 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-mail": "self.version" - }, - "suggest": { - "zendframework/zend-mail": "Zend\\Mail component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/ModuleManager/Listener/ConfigListener.php b/library/Zend/ModuleManager/Listener/ConfigListener.php index 8d2e9d4dd19..f19729b3022 100644 --- a/library/Zend/ModuleManager/Listener/ConfigListener.php +++ b/library/Zend/ModuleManager/Listener/ConfigListener.php @@ -89,8 +89,8 @@ public function attach(EventManagerInterface $events) } $this->callbacks[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, array($this, 'onLoadModule')); - $this->callbacks[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULES, array($this, 'onLoadModules'), -1000); - $this->callbacks[] = $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'onMergeConfig'), 1000); + $this->callbacks[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULES, array($this, 'onLoadModulesPost'), -1000); + return $this; } @@ -137,7 +137,7 @@ public function onLoadModule(ModuleEvent $e) * @param ModuleEvent $e * @return ConfigListener */ - public function onMergeConfig(ModuleEvent $e) + public function onLoadModulesPost(ModuleEvent $e) { // Load the config files foreach ($this->paths as $path) { @@ -150,24 +150,6 @@ public function onMergeConfig(ModuleEvent $e) $this->mergedConfig = ArrayUtils::merge($this->mergedConfig, $config); } - return $this; - } - - /** - * Optionally cache merged config - * - * This is only attached if config is not cached. - * - * @param ModuleEvent $e - * @return ConfigListener - */ - public function onLoadModules(ModuleEvent $e) - { - - // Trigger MERGE_CONFIG event. This is a hook to allow the merged application config to be - // modified before it is cached (In particular, allows the removal of config keys) - $e->getTarget()->getEventManager()->trigger(ModuleEvent::EVENT_MERGE_CONFIG, $e->getTarget(), $e); - // If enabled, update the config cache if ( $this->getOptions()->getConfigCacheEnabled() diff --git a/library/Zend/ModuleManager/ModuleEvent.php b/library/Zend/ModuleManager/ModuleEvent.php index c19b9976322..c81e773d55c 100644 --- a/library/Zend/ModuleManager/ModuleEvent.php +++ b/library/Zend/ModuleManager/ModuleEvent.php @@ -20,11 +20,10 @@ class ModuleEvent extends Event /** * Module events triggered by eventmanager */ - const EVENT_MERGE_CONFIG = 'mergeConfig'; - const EVENT_LOAD_MODULES = 'loadModules'; - const EVENT_LOAD_MODULE_RESOLVE = 'loadModule.resolve'; - const EVENT_LOAD_MODULE = 'loadModule'; - const EVENT_LOAD_MODULES_POST = 'loadModules.post'; + CONST EVENT_LOAD_MODULES = 'loadModules'; + CONST EVENT_LOAD_MODULE_RESOLVE = 'loadModule.resolve'; + CONST EVENT_LOAD_MODULE = 'loadModule'; + CONST EVENT_LOAD_MODULES_POST = 'loadModules.post'; /** * @var mixed diff --git a/library/Zend/ModuleManager/composer.json b/library/Zend/ModuleManager/composer.json index 0105a3ec2da..40ad41ab7cb 100644 --- a/library/Zend/ModuleManager/composer.json +++ b/library/Zend/ModuleManager/composer.json @@ -17,18 +17,9 @@ "zendframework/zend-eventmanager": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-config": "self.version", - "zendframework/zend-console": "self.version", - "zendframework/zend-loader": "self.version", - "zendframework/zend-mvc": "self.version", - "zendframework/zend-servicemanager": "self.version" - }, "suggest": { "zendframework/zend-config": "Zend\\Config component", - "zendframework/zend-console": "Zend\\Console component", "zendframework/zend-loader": "Zend\\Loader component", - "zendframework/zend-mvc": "Zend\\Mvc component", "zendframework/zend-servicemanager": "Zend\\ServiceManager component" }, "extra": { diff --git a/library/Zend/Mvc/Application.php b/library/Zend/Mvc/Application.php index 244942fa39a..093a299b7b7 100644 --- a/library/Zend/Mvc/Application.php +++ b/library/Zend/Mvc/Application.php @@ -268,7 +268,7 @@ public static function init($configuration = array()) * discovered controller, and controller class (if known). * Typically, a handler should return a populated Response object * that can be returned immediately. - * @return self + * @return ResponseInterface */ public function run() { @@ -294,13 +294,12 @@ public function run() $event->setTarget($this); $event->setResponse($response); $events->trigger(MvcEvent::EVENT_FINISH, $event); - $this->response = $response; - return $this; + return $response; } if ($event->getError()) { return $this->completeRequest($event); } - return $this; + return $event->getResponse(); } if ($event->getError()) { return $this->completeRequest($event); @@ -315,8 +314,7 @@ public function run() $event->setTarget($this); $event->setResponse($response); $events->trigger(MvcEvent::EVENT_FINISH, $event); - $this->response = $response; - return $this; + return $response; } $response = $this->getResponse(); diff --git a/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php b/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php index fc45d7c45a7..f340f91333f 100644 --- a/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php +++ b/library/Zend/Mvc/Controller/Plugin/FlashMessenger.php @@ -31,11 +31,6 @@ class FlashMessenger extends AbstractPlugin implements IteratorAggregate, Counta */ const NAMESPACE_SUCCESS = 'success'; - /** - * Warning messages namespace - */ - const NAMESPACE_WARNING = 'warning'; - /** * Error messages namespace */ @@ -209,22 +204,6 @@ public function addSuccessMessage($message) return $this; } - /** - * Add a message with "warning" type - * - * @param string $message - * @return FlashMessenger - */ - public function addWarningMessage($message) - { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $this->addMessage($message); - $this->setNamespace($namespace); - - return $this; - } - /** * Add a message with "error" type * @@ -283,21 +262,6 @@ public function hasSuccessMessages() return $hasMessages; } - /** - * Whether "warning" namespace has messages - * - * @return bool - */ - public function hasWarningMessages() - { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $hasMessages = $this->hasMessages(); - $this->setNamespace($namespace); - - return $hasMessages; - } - /** * Whether "error" namespace has messages * @@ -357,21 +321,6 @@ public function getSuccessMessages() return $messages; } - /** - * Get messages from "warning" namespace - * - * @return array - */ - public function getWarningMessages() - { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $messages = $this->getMessages(); - $this->setNamespace($namespace); - - return $messages; - } - /** * Get messages from "error" namespace * @@ -482,22 +431,6 @@ public function hasCurrentSuccessMessages() return $hasMessages; } - /** - * Check to see if messages have been added to "warning" - * namespace within this request - * - * @return bool - */ - public function hasCurrentWarningMessages() - { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $hasMessages = $this->hasCurrentMessages(); - $this->setNamespace($namespace); - - return $hasMessages; - } - /** * Check to see if messages have been added to "error" * namespace within this request @@ -564,22 +497,6 @@ public function getCurrentSuccessMessages() return $messages; } - /** - * Get messages that have been added to the "warning" - * namespace within this request - * - * @return array - */ - public function getCurrentWarningMessages() - { - $namespace = $this->getNamespace(); - $this->setNamespace(self::NAMESPACE_WARNING); - $messages = $this->getCurrentMessages(); - $this->setNamespace($namespace); - - return $messages; - } - /** * Get messages that have been added to the "error" * namespace within this request diff --git a/library/Zend/Mvc/Router/Console/Simple.php b/library/Zend/Mvc/Router/Console/Simple.php index f0cea23ec27..14e2c91fe11 100644 --- a/library/Zend/Mvc/Router/Console/Simple.php +++ b/library/Zend/Mvc/Router/Console/Simple.php @@ -13,9 +13,7 @@ namespace Zend\Mvc\Router\Console; use Traversable; -use Zend\Console\RouteMatcher\DefaultRouteMatcher; use Zend\Console\Request as ConsoleRequest; -use Zend\Console\RouteMatcher\RouteMatcherInterface; use Zend\Filter\FilterChain; use Zend\Mvc\Exception\InvalidArgumentException; use Zend\Mvc\Router\Exception; @@ -32,6 +30,26 @@ */ class Simple implements RouteInterface { + /** + * Parts of the route. + * + * @var array + */ + protected $parts; + + /** + * Default values. + * + * @var array + */ + protected $defaults; + + /** + * Parameters' name aliases. + * + * @var array + */ + protected $aliases; /** * List of assembled parameters. @@ -41,39 +59,69 @@ class Simple implements RouteInterface protected $assembledParams = array(); /** - * @var RouteMatcherInterface + * @var \Zend\Validator\ValidatorChain */ - protected $matcher; + protected $validators; + + /** + * @var \Zend\Filter\FilterChain + */ + protected $filters; /** * Create a new simple console route. * - * @param string|RouteMatcherInterface $routeOrRouteMatcher + * @param string $route * @param array $constraints * @param array $defaults * @param array $aliases * @param null|array|Traversable|FilterChain $filters * @param null|array|Traversable|ValidatorChain $validators - * @throws InvalidArgumentException + * @throws \Zend\Mvc\Exception\InvalidArgumentException + * @return \Zend\Mvc\Router\Console\Simple */ public function __construct( - $routeOrRouteMatcher, + $route, array $constraints = array(), array $defaults = array(), array $aliases = array(), $filters = null, $validators = null ) { - if (is_string($routeOrRouteMatcher)) { - $this->matcher = new DefaultRouteMatcher($routeOrRouteMatcher, $constraints, $defaults, $aliases); - } elseif ($routeOrRouteMatcher instanceof RouteMatcherInterface) { - $this->matcher = $routeOrRouteMatcher; - } else { - throw new InvalidArgumentException( - "routeOrRouteMatcher should either be string, or class implementing RouteMatcherInterface. " - . gettype($routeOrRouteMatcher) . " was given." - ); + $this->defaults = $defaults; + $this->constraints = $constraints; + $this->aliases = $aliases; + + if ($filters !== null) { + if ($filters instanceof FilterChain) { + $this->filters = $filters; + } elseif ($filters instanceof Traversable) { + $this->filters = new FilterChain(array( + 'filters' => ArrayUtils::iteratorToArray($filters, false) + )); + } elseif (is_array($filters)) { + $this->filters = new FilterChain(array( + 'filters' => $filters + )); + } else { + throw new InvalidArgumentException('Cannot use ' . gettype($filters) . ' as filters for ' . __CLASS__); + } + } + + if ($validators !== null) { + if ($validators instanceof ValidatorChain) { + $this->validators = $validators; + } elseif ($validators instanceof Traversable || is_array($validators)) { + $this->validators = new ValidatorChain(); + foreach ($validators as $v) { + $this->validators->attach($v); + } + } else { + throw new InvalidArgumentException('Cannot use ' . gettype($validators) . ' as validators for ' . __CLASS__); + } } + + $this->parts = $this->parseRouteDefinition($route); } /** @@ -81,19 +129,19 @@ public function __construct( * * @see \Zend\Mvc\Router\RouteInterface::factory() * @param array|Traversable $options - * @throws InvalidArgumentException - * @return self + * @throws \Zend\Mvc\Router\Exception\InvalidArgumentException + * @return Simple */ public static function factory($options = array()) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { - throw new InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); + throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options'); } if (!isset($options['route'])) { - throw new InvalidArgumentException('Missing "route" in options array'); + throw new Exception\InvalidArgumentException('Missing "route" in options array'); } foreach (array( @@ -125,6 +173,357 @@ public static function factory($options = array()) ); } + /** + * Parse a route definition. + * + * @param string $def + * @return array + * @throws Exception\InvalidArgumentException + */ + protected function parseRouteDefinition($def) + { + $def = trim($def); + $pos = 0; + $length = strlen($def); + $parts = array(); + $unnamedGroupCounter = 1; + + while ($pos < $length) { + /** + * Mandatory long param + * --param= + * --param=whatever + */ + if (preg_match('/\G--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+)(?P=\S*?)?(?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => $m['name'], + 'short' => false, + 'literal' => false, + 'required' => true, + 'positional' => false, + 'hasValue' => !empty($m['hasValue']), + ); + } + /** + * Optional long flag + * [--param] + */ + elseif (preg_match( + '/\G\[ *?--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+) *?\](?: +|$)/s', $def, $m, 0, $pos + )) { + $item = array( + 'name' => $m['name'], + 'short' => false, + 'literal' => false, + 'required' => false, + 'positional' => false, + 'hasValue' => false, + ); + } + /** + * Optional long param + * [--param=] + * [--param=whatever] + */ + elseif (preg_match( + '/\G\[ *?--(?P[a-zA-Z0-9][a-zA-Z0-9\_\-]+)(?P=\S*?)? *?\](?: +|$)/s', $def, $m, 0, $pos + )) { + $item = array( + 'name' => $m['name'], + 'short' => false, + 'literal' => false, + 'required' => false, + 'positional' => false, + 'hasValue' => !empty($m['hasValue']), + ); + } + /** + * Mandatory short param + * -a + * -a=i + * -a=s + * -a=w + */ + elseif (preg_match('/\G-(?P[a-zA-Z0-9])(?:=(?P[ns]))?(?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => $m['name'], + 'short' => true, + 'literal' => false, + 'required' => true, + 'positional' => false, + 'hasValue' => !empty($m['type']) ? $m['type'] : null, + ); + } + /** + * Optional short param + * [-a] + * [-a=n] + * [-a=s] + */ + elseif (preg_match('/\G\[ *?-(?P[a-zA-Z0-9])(?:=(?P[ns]))? *?\](?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => $m['name'], + 'short' => true, + 'literal' => false, + 'required' => false, + 'positional' => false, + 'hasValue' => !empty($m['type']) ? $m['type'] : null, + ); + } + /** + * Optional literal param alternative + * [ something | somethingElse | anotherOne ] + * [ something | somethingElse | anotherOne ]:namedGroup + */ + elseif (preg_match('/ + \G + \[ + (?P + (?: + \ *? + (?P[a-z0-9][a-zA-Z0-9_\-]*?) + \ *? + (?:\||(?=\])) + \ *? + )+ + ) + \] + (?:\:(?P[a-zA-Z0-9]+))? + (?:\ +|$) + /sx', $def, $m, 0, $pos + ) + ) { + // extract available options + $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); + + // remove dupes + array_unique($options); + + // prepare item + $item = array( + 'name' => isset($m['groupName']) ? $m['groupName'] : 'unnamedGroup' . $unnamedGroupCounter++, + 'literal' => true, + 'required' => false, + 'positional' => true, + 'alternatives' => $options, + 'hasValue' => false, + ); + } + + /** + * Required literal param alternative + * ( something | somethingElse | anotherOne ) + * ( something | somethingElse | anotherOne ):namedGroup + */ + elseif (preg_match('/ + \G + \( + (?P + (?: + \ *? + (?P[a-z0-9][a-zA-Z0-9_\-]+) + \ *? + (?:\||(?=\))) + \ *? + )+ + ) + \) + (?:\:(?P[a-zA-Z0-9]+))? + (?:\ +|$) + /sx', $def, $m, 0, $pos + )) { + // extract available options + $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); + + // remove dupes + array_unique($options); + + // prepare item + $item = array( + 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, + 'literal' => true, + 'required' => true, + 'positional' => true, + 'alternatives' => $options, + 'hasValue' => false, + ); + } + /** + * Required long/short flag alternative + * ( --something | --somethingElse | --anotherOne | -s | -a ) + * ( --something | --somethingElse | --anotherOne | -s | -a ):namedGroup + */ + elseif (preg_match('/ + \G + \( + (?P + (?: + \ *? + \-+(?P[a-zA-Z0-9][a-zA-Z0-9_\-]*?) + \ *? + (?:\||(?=\))) + \ *? + )+ + ) + \) + (?:\:(?P[a-zA-Z0-9]+))? + (?:\ +|$) + /sx', $def, $m, 0, $pos + )) { + // extract available options + $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); + + // remove dupes + array_unique($options); + + // remove prefix + array_walk($options, function (&$val, $key) { + $val = ltrim($val, '-'); + }); + + // prepare item + $item = array( + 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, + 'literal' => false, + 'required' => true, + 'positional' => false, + 'alternatives' => $options, + 'hasValue' => false, + ); + } + /** + * Optional flag alternative + * [ --something | --somethingElse | --anotherOne | -s | -a ] + * [ --something | --somethingElse | --anotherOne | -s | -a ]:namedGroup + */ + elseif (preg_match('/ + \G + \[ + (?P + (?: + \ *? + \-+(?P[a-zA-Z0-9][a-zA-Z0-9_\-]*?) + \ *? + (?:\||(?=\])) + \ *? + )+ + ) + \] + (?:\:(?P[a-zA-Z0-9]+))? + (?:\ +|$) + /sx', $def, $m, 0, $pos + )) { + // extract available options + $options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY); + + // remove dupes + array_unique($options); + + // remove prefix + array_walk($options, function (&$val, $key) { + $val = ltrim($val, '-'); + }); + + // prepare item + $item = array( + 'name' => isset($m['groupName']) ? $m['groupName']:'unnamedGroupAt' . $unnamedGroupCounter++, + 'literal' => false, + 'required' => false, + 'positional' => false, + 'alternatives' => $options, + 'hasValue' => false, + ); + } + /** + * Optional literal param, i.e. + * [something] + */ + elseif (preg_match('/\G\[ *?(?P[a-z0-9][a-zA-Z0-9\_\-]*?) *?\](?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => $m['name'], + 'literal' => true, + 'required' => false, + 'positional' => true, + 'hasValue' => false, + ); + } + /** + * Optional value param, i.e. + * [SOMETHING] + */ + elseif (preg_match('/\G\[(?P[a-z0-9][a-zA-Z0-9\_\-]*?)\](?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => strtolower($m['name']), + 'literal' => false, + 'required' => false, + 'positional' => true, + 'hasValue' => true, + ); + } + /** + * Optional value param, syntax 2, i.e. + * [] + */ + elseif (preg_match('/\G\[ *\<(?P[a-z0-9][a-zA-Z0-9\_\-]*?)\> *\](?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => strtolower($m['name']), + 'literal' => false, + 'required' => false, + 'positional' => true, + 'hasValue' => true, + ); + } + /** + * Mandatory value param, i.e. + * + */ + elseif (preg_match('/\G\< *(?P[a-z0-9][a-zA-Z0-9\_\-]*?) *\>(?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => $m['name'], + 'literal' => false, + 'required' => true, + 'positional' => true, + 'hasValue' => true, + ); + } + /** + * Mandatory value param, i.e. + * SOMETHING + */ + elseif (preg_match('/\G(?P[A-Z][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => strtolower($m['name']), + 'literal' => false, + 'required' => true, + 'positional' => true, + 'hasValue' => true, + ); + } + /** + * Mandatory literal param, i.e. + * something + */ + elseif (preg_match('/\G(?P[a-z0-9][a-zA-Z0-9\_\-]*?)(?: +|$)/s', $def, $m, 0, $pos)) { + $item = array( + 'name' => $m['name'], + 'literal' => true, + 'required' => true, + 'positional' => true, + 'hasValue' => false, + ); + } else { + throw new Exception\InvalidArgumentException( + 'Cannot understand Console route at "' . substr($def, $pos) . '"' + ); + } + + $pos += strlen($m[0]); + $parts[] = $item; + } + + return $parts; + } + /** * match(): defined by Route interface. * @@ -139,13 +538,279 @@ public function match(Request $request, $pathOffset = null) return null; } - $params = $request->getParams()->toArray(); - $matches = $this->matcher->match($params); + /** @var $request ConsoleRequest */ + /** @var $params \Zend\Stdlib\Parameters */ + $params = $request->getParams()->toArray(); + $matches = array(); + + /** + * Extract positional and named parts + */ + $positional = $named = array(); + foreach ($this->parts as &$part) { + if ($part['positional']) { + $positional[] = &$part; + } else { + $named[] = &$part; + } + } + + /** + * Scan for named parts inside Console params + */ + foreach ($named as &$part) { + /** + * Prepare match regex + */ + if (isset($part['alternatives'])) { + // an alternative of flags + $regex = '/^\-+(?P'; + $regex .= join('|', $part['alternatives']); + + if ($part['hasValue']) { + $regex .= ')(?:\=(?P.*?)$)?$/'; + } else { + $regex .= ')$/i'; + } + } else { + // a single named flag + if ($part['short'] === true) { + // short variant + if ($part['hasValue']) { + $regex = '/^\-' . $part['name'] . '(?:\=(?P.*?)$)?$/i'; + } else { + $regex = '/^\-' . $part['name'] . '$/i'; + } + } elseif ($part['short'] === false) { + // long variant + if ($part['hasValue']) { + $regex = '/^\-{2,}' . $part['name'] . '(?:\=(?P.*?)$)?$/i'; + } else { + $regex = '/^\-{2,}' . $part['name'] . '$/i'; + } + } + } + + /** + * Look for param + */ + $value = $param = null; + for ($x = 0, $count = count($params); $x < $count; $x++) { + if (preg_match($regex, $params[$x], $m)) { + // found param + $param = $params[$x]; + + // prevent further scanning of this param + array_splice($params, $x, 1); + + if (isset($m['value'])) { + $value = $m['value']; + } + + if (isset($m['name'])) { + $matchedName = $m['name']; + } + + break; + } + } + + + if (!$param) { + /** + * Drop out if that was a mandatory param + */ + if ($part['required']) { + return null; + } + + /** + * Continue to next positional param + */ + else { + continue; + } + } + + + /** + * Value for flags is always boolean + */ + if ($param && !$part['hasValue']) { + $value = true; + } + + /** + * Try to retrieve value if it is expected + */ + if ((null === $value || "" === $value) && $part['hasValue']) { + if ($x < count($params)+1 && isset($params[$x])) { + // retrieve value from adjacent param + $value = $params[$x]; + + // prevent further scanning of this param + array_splice($params, $x, 1); + } else { + // there are no more params available + return null; + } + } + + /** + * Validate the value against constraints + */ + if ($part['hasValue'] && isset($this->constraints[$part['name']])) { + if ( + !preg_match($this->constraints[$part['name']], $value) + ) { + // constraint failed + return null; + } + } + + /** + * Store the value + */ + if ($part['hasValue']) { + $matches[$part['name']] = $value; + } else { + $matches[$part['name']] = true; + } + + /** + * If there are alternatives, fill them + */ + if (isset($part['alternatives'])) { + if ($part['hasValue']) { + foreach ($part['alternatives'] as $alt) { + if ($alt === $matchedName && !isset($matches[$alt])) { + $matches[$alt] = $value; + } elseif (!isset($matches[$alt])) { + $matches[$alt] = null; + } + } + } else { + foreach ($part['alternatives'] as $alt) { + if ($alt === $matchedName && !isset($matches[$alt])) { + $matches[$alt] = isset($this->defaults[$alt])? $this->defaults[$alt] : true; + } elseif (!isset($matches[$alt])) { + $matches[$alt] = false; + } + } + } + } + } + + /** + * Scan for left-out flags that should result in a mismatch + */ + foreach ($params as $param) { + if (preg_match('#^\-+#', $param)) { + return null; // there is an unrecognized flag + } + } + + /** + * Go through all positional params + */ + $argPos = 0; + foreach ($positional as &$part) { + /** + * Check if param exists + */ + if (!isset($params[$argPos])) { + if ($part['required']) { + // cannot find required positional param + return null; + } else { + // stop matching + break; + } + } + + $value = $params[$argPos]; + + /** + * Check if literal param matches + */ + if ($part['literal']) { + if ( + (isset($part['alternatives']) && !in_array($value, $part['alternatives'])) || + (!isset($part['alternatives']) && $value != $part['name']) + ) { + return null; + } + } + + /** + * Validate the value against constraints + */ + if ($part['hasValue'] && isset($this->constraints[$part['name']])) { + if ( + !preg_match($this->constraints[$part['name']], $value) + ) { + // constraint failed + return null; + } + } + + /** + * Store the value + */ + if ($part['hasValue']) { + $matches[$part['name']] = $value; + } elseif (isset($part['alternatives'])) { + // from all alternativesm set matching parameter to TRUE and the rest to FALSE + foreach ($part['alternatives'] as $alt) { + if ($alt == $value) { + $matches[$alt] = isset($this->defaults[$alt])? $this->defaults[$alt] : true; + } else { + $matches[$alt] = false; + } + } + + // set alternatives group value + $matches[$part['name']] = $value; + } elseif (!$part['required']) { + // set optional parameter flag + $name = $part['name']; + $matches[$name] = isset($this->defaults[$name])? $this->defaults[$name] : true; + } + + /** + * Advance to next argument + */ + $argPos++; - if (null !== $matches) { - return new RouteMatch($matches); } - return null; + + /** + * Check if we have consumed all positional parameters + */ + if ($argPos < count($params)) { + return null; // there are extraneous params that were not consumed + } + + /** + * Any optional flags that were not entered have value false + */ + foreach ($this->parts as &$part) { + if (!$part['required'] && !$part['hasValue']) { + if (!isset($matches[$part['name']])) { + $matches[$part['name']] = false; + } + // unset alternatives also should be false + if (isset($part['alternatives'])) { + foreach ($part['alternatives'] as $alt) { + if (!isset($matches[$alt])) { + $matches[$alt] = false; + } + } + } + } + } + + return new RouteMatch(array_replace($this->defaults, $matches)); } /** diff --git a/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php b/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php index 3ee180f4e4d..4fd597f4d0d 100644 --- a/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php +++ b/library/Zend/Mvc/View/Console/DefaultRenderingStrategy.php @@ -66,18 +66,10 @@ public function render(MvcEvent $e) $responseText .= $result->getVariable(ConsoleViewModel::RESULT); } - // Fetch service manager - $sm = $e->getApplication()->getServiceManager(); - - // Fetch console - $console = $sm->get('console'); - // Append console response to response object - $content = $response->getContent() . $responseText; - if (is_callable(array($console, 'encodeText'))) { - $content = $console->encodeText($content); - } - $response->setContent($content); + $response->setContent( + $response->getContent() . $responseText + ); // Pass on console-specific options if ($response instanceof ConsoleResponse diff --git a/library/Zend/Mvc/composer.json b/library/Zend/Mvc/composer.json index 2ea114415cf..b21a903b88c 100644 --- a/library/Zend/Mvc/composer.json +++ b/library/Zend/Mvc/composer.json @@ -18,44 +18,22 @@ "zendframework/zend-servicemanager": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-authentication": "self.version", - "zendframework/zend-console": "self.version", - "zendframework/zend-di": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-form": "self.version", - "zendframework/zend-http": "self.version", - "zendframework/zend-i18n": "self.version", - "zendframework/zend-inputfilter": "self.version", - "zendframework/zend-json": "self.version", - "zendframework/zend-modulemanager": "self.version", - "zendframework/zend-session": "self.version", - "zendframework/zend-serializer": "self.version", - "zendframework/zend-text": "self.version", - "zendframework/zend-uri": "self.version", - "zendframework/zend-validator": "self.version", - "zendframework/zend-version": "self.version", - "zendframework/zend-view": "self.version" - }, "suggest": { - "zendframework/zend-authentication": "Zend\\Authentication component", + "zendframework/zend-config": "Zend\\Config component", "zendframework/zend-console": "Zend\\Console component", "zendframework/zend-di": "Zend\\Di component", "zendframework/zend-filter": "Zend\\Filter component", - "zendframework/zend-form": "Zend\\Form component", "zendframework/zend-http": "Zend\\Http component", + "zendframework/zend-form": "Zend\\Form component", "zendframework/zend-i18n": "Zend\\I18n component for translatable segments", "zendframework/zend-inputfilter": "Zend\\Inputfilter component", - "zendframework/zend-json": "Zend\\Json component", "zendframework/zend-modulemanager": "Zend\\ModuleManager component", - "zendframework/zend-session": "Zend\\Session component", "zendframework/zend-serializer": "Zend\\Serializer component", + "zendframework/zend-stdlib": "Zend\\Stdlib component", "zendframework/zend-text": "Zend\\Text component", "zendframework/zend-uri": "Zend\\Uri component", "zendframework/zend-validator": "Zend\\Validator component", - "zendframework/zend-version": "Zend\\Version component", "zendframework/zend-view": "Zend\\View component" - }, "extra": { "branch-alias": { diff --git a/library/Zend/Navigation/Page/Uri.php b/library/Zend/Navigation/Page/Uri.php index 7514ae7ed8f..338e937be53 100644 --- a/library/Zend/Navigation/Page/Uri.php +++ b/library/Zend/Navigation/Page/Uri.php @@ -9,7 +9,6 @@ namespace Zend\Navigation\Page; -use Zend\Http\Request; use Zend\Navigation\Exception; /** @@ -24,13 +23,6 @@ class Uri extends AbstractPage */ protected $uri = null; - /** - * Request object used to determine uri path - * - * @var string - */ - protected $request; - /** * Sets page URI * @@ -84,53 +76,6 @@ public function getHref() return $uri; } - /** - * Returns whether page should be considered active or not - * - * This method will compare the page properties against the request uri. - * - * @param bool $recursive - * [optional] whether page should be considered - * active if any child pages are active. Default is - * false. - * @return bool whether page should be considered active or not - */ - public function isActive($recursive = false) - { - if (!$this->active) { - if ($this->getRequest() instanceof Request) { - if ($this->getRequest()->getUri()->getPath() == $this->getUri()) { - $this->active = true; - return true; - } - } - } - - return parent::isActive($recursive); - } - - /** - * Get the request - * - * @return Request - */ - public function getRequest() - { - return $this->request; - } - - /** - * Sets request for assembling URLs - * - * @param Request $request - * @return Fluent interface, returns self - */ - public function setRequest(Request $request = null) - { - $this->request = $request; - return $this; - } - /** * Returns an array representation of the page * diff --git a/library/Zend/Navigation/Service/AbstractNavigationFactory.php b/library/Zend/Navigation/Service/AbstractNavigationFactory.php index 807d8a1d435..f5af421edc2 100644 --- a/library/Zend/Navigation/Service/AbstractNavigationFactory.php +++ b/library/Zend/Navigation/Service/AbstractNavigationFactory.php @@ -10,7 +10,6 @@ namespace Zend\Navigation\Service; use Zend\Config; -use Zend\Http\Request; use Zend\Mvc\Router\RouteMatch; use Zend\Mvc\Router\RouteStackInterface as Router; use Zend\Navigation\Exception; @@ -80,14 +79,8 @@ protected function preparePages(ServiceLocatorInterface $serviceLocator, $pages) $application = $serviceLocator->get('Application'); $routeMatch = $application->getMvcEvent()->getRouteMatch(); $router = $application->getMvcEvent()->getRouter(); - $request = $application->getMvcEvent()->getRequest(); - // HTTP request is the only one that may be injected - if (!$request instanceof Request) { - $request = null; - } - - return $this->injectComponents($pages, $routeMatch, $router, $request); + return $this->injectComponents($pages, $routeMatch, $router); } /** @@ -121,13 +114,11 @@ protected function getPagesFromConfig($config = null) * @param array $pages * @param RouteMatch $routeMatch * @param Router $router - * @param null|Request $request * @return mixed */ - protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null, $request = null) + protected function injectComponents(array $pages, RouteMatch $routeMatch = null, Router $router = null) { foreach ($pages as &$page) { - $hasUri = isset($page['uri']); $hasMvc = isset($page['action']) || isset($page['controller']) || isset($page['route']); if ($hasMvc) { if (!isset($page['routeMatch']) && $routeMatch) { @@ -136,17 +127,12 @@ protected function injectComponents(array $pages, RouteMatch $routeMatch = null, if (!isset($page['router'])) { $page['router'] = $router; } - } elseif ($hasUri) { - if (!isset($page['request'])) { - $page['request'] = $request; - } } if (isset($page['pages'])) { - $page['pages'] = $this->injectComponents($page['pages'], $routeMatch, $router, $request); + $page['pages'] = $this->injectComponents($page['pages'], $routeMatch, $router); } } return $pages; } - } diff --git a/library/Zend/Navigation/composer.json b/library/Zend/Navigation/composer.json index 3178098e76a..b395d0ad219 100644 --- a/library/Zend/Navigation/composer.json +++ b/library/Zend/Navigation/composer.json @@ -16,18 +16,9 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-config": "self.version", - "zendframework/zend-mvc": "self.version", - "zendframework/zend-permissions-acl": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-view": "self.version" - }, "suggest": { "zendframework/zend-config": "Zend\\Config component", "zendframework/zend-mvc": "Zend\\Mvc component", - "zendframework/zend-permissions-acl": "Zend\\Permissions\\Acl component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", "zendframework/zend-view": "Zend\\View component" }, "extra": { diff --git a/library/Zend/Paginator/Adapter/DbTableGateway.php b/library/Zend/Paginator/Adapter/DbTableGateway.php index 04c26541763..b667ee0e3d5 100644 --- a/library/Zend/Paginator/Adapter/DbTableGateway.php +++ b/library/Zend/Paginator/Adapter/DbTableGateway.php @@ -10,7 +10,6 @@ namespace Zend\Paginator\Adapter; use Zend\Db\Sql\Where; -use Zend\Db\Sql\Having; use Zend\Db\TableGateway\TableGateway; use Zend\Paginator\Adapter\DbSelect; @@ -19,30 +18,23 @@ class DbTableGateway extends DbSelect /** * Constructs instance. * - * @param TableGateway $tableGateway - * @param null|Where|\Closure|string|array $where - * @param null|string|array $order - * @param null|string|array $group - * @param null|Having|\Closure|string|array $having + * @param TableGateway $tableGateway + * @param Where|\Closure|string|array $where + * @param null $order */ - public function __construct(TableGateway $tableGateway, $where = null, $order = null, $group = null, $having = null) + public function __construct(TableGateway $tableGateway, $where = null, $order = null) { - $sql = $tableGateway->getSql(); - $select = $sql->select(); + $select = $tableGateway->getSql()->select(); if ($where) { $select->where($where); } if ($order) { $select->order($order); } - if ($group) { - $select->group($group); - } - if ($having) { - $select->having($having); - } + $dbAdapter = $tableGateway->getAdapter(); $resultSetPrototype = $tableGateway->getResultSetPrototype(); - parent::__construct($select, $sql, $resultSetPrototype); + + parent::__construct($select, $dbAdapter, $resultSetPrototype); } } diff --git a/library/Zend/Paginator/composer.json b/library/Zend/Paginator/composer.json index 495381c3ddb..cdfe4a8f63f 100644 --- a/library/Zend/Paginator/composer.json +++ b/library/Zend/Paginator/composer.json @@ -16,22 +16,6 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-cache": "self.version", - "zendframework/zend-db": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-json": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-view": "self.version" - }, - "suggest": { - "zendframework/zend-cache": "Zend\\Cache component", - "zendframework/zend-db": "Zend\\Db component", - "zendframework/zend-filter": "Zend\\Filter component", - "zendframework/zend-json": "Zend\\Json component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-view": "Zend\\View component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/ProgressBar/composer.json b/library/Zend/ProgressBar/composer.json index 6b32a5f564f..4fbe59c0f61 100644 --- a/library/Zend/ProgressBar/composer.json +++ b/library/Zend/ProgressBar/composer.json @@ -16,13 +16,8 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-json": "self.version", - "zendframework/zend-session": "self.version" - }, "suggest": { - "zendframework/zend-json": "Zend\\Json component", - "zendframework/zend-session": "Zend\\Session component" + "zendframework/zend-json": "Zend\\Json component" }, "extra": { "branch-alias": { diff --git a/library/Zend/Serializer/composer.json b/library/Zend/Serializer/composer.json index 070a555f1f7..6c1ec8e5e23 100644 --- a/library/Zend/Serializer/composer.json +++ b/library/Zend/Serializer/composer.json @@ -18,9 +18,6 @@ "zendframework/zend-json": "self.version", "zendframework/zend-math": "self.version" }, - "require-dev": { - "zendframework/zend-servicemanager": "self.version" - }, "suggest": { "zendframework/zend-servicemanager": "To support plugin manager support" }, diff --git a/library/Zend/ServiceManager/composer.json b/library/Zend/ServiceManager/composer.json index 0014620c5a0..15e65e28e3b 100644 --- a/library/Zend/ServiceManager/composer.json +++ b/library/Zend/ServiceManager/composer.json @@ -15,9 +15,6 @@ "require": { "php": ">=5.3.3" }, - "require-dev": { - "zendframework/zend-di": "self.version" - }, "suggest": { "zendframework/zend-di": "Zend\\Di component" }, diff --git a/library/Zend/Session/composer.json b/library/Zend/Session/composer.json index a74ba699172..ba47ac2b93c 100644 --- a/library/Zend/Session/composer.json +++ b/library/Zend/Session/composer.json @@ -16,19 +16,8 @@ "php": ">=5.3.3", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-cache": "self.version", - "zendframework/zend-db": "self.version", - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-http": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-validator": "self.version" - }, "suggest": { - "zendframework/zend-cache": "Zend\\Cache component", - "zendframework/zend-db": "Zend\\Db component", "zendframework/zend-eventmanager": "Zend\\EventManager component", - "zendframework/zend-http": "Zend\\Http component", "zendframework/zend-servicemanager": "Zend\\ServiceManager component", "zendframework/zend-validator": "Zend\\Validator component" }, diff --git a/library/Zend/Soap/composer.json b/library/Zend/Soap/composer.json index 5407a665335..fe3190017c2 100644 --- a/library/Zend/Soap/composer.json +++ b/library/Zend/Soap/composer.json @@ -18,12 +18,6 @@ "zendframework/zend-stdlib": "self.version", "zendframework/zend-uri": "self.version" }, - "require-dev": { - "zendframework/zend-http": "self.version" - }, - "suggest": { - "zendframework/zend-http": "Zend\\Http component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Stdlib/Hydrator/AbstractHydrator.php b/library/Zend/Stdlib/Hydrator/AbstractHydrator.php index 76ccdc1f1f0..4cb9a4356f7 100644 --- a/library/Zend/Stdlib/Hydrator/AbstractHydrator.php +++ b/library/Zend/Stdlib/Hydrator/AbstractHydrator.php @@ -15,7 +15,7 @@ use Zend\Stdlib\Hydrator\StrategyEnabledInterface; use Zend\Stdlib\Hydrator\Strategy\StrategyInterface; -abstract class AbstractHydrator implements HydratorInterface, StrategyEnabledInterface, FilterEnabledInterface +abstract class AbstractHydrator implements HydratorInterface, StrategyEnabledInterface { /** * The list with strategies that this hydrator has. diff --git a/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php b/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php deleted file mode 100644 index 8b3105f5ede..00000000000 --- a/library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * $composite->addFilter( - * "servicelocator", - * function($property) { - * list($class, $method) = explode('::', $property); - * if ($method === 'getServiceLocator') { - * return false; - * } - * return true; - * }, - * FilterComposite::CONDITION_AND - * ); - * - * - * @param string $name Index in the composite - * @param callable|FilterInterface $filter - * @param int $condition - * @return FilterComposite - */ - public function addFilter($name, $filter, $condition = FilterComposite::CONDITION_OR); - - /** - * Check whether a specific filter exists at key $name or not - * - * @param string $name Index in the composite - * @return bool - */ - public function hasFilter($name); - - /** - * Remove a filter from the composition. - * To not extract "has" methods, you simply need to unregister it - * - * - * $filterComposite->removeFilter('has'); - * - * - * @param $name - * @return FilterComposite - */ - public function removeFilter($name); -} diff --git a/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php b/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php deleted file mode 100644 index 5ccd8419181..00000000000 --- a/library/Zend/Stdlib/Hydrator/HydratorAwareTrait.php +++ /dev/null @@ -1,49 +0,0 @@ -hydrator = $hydrator; - - return $this; - } - - /** - * Retrieve hydrator - * - * @param void - * @return null|HydratorInterface - * @access public - */ - public function getHydrator() - { - return $this->hydrator; - } -} diff --git a/library/Zend/Stdlib/JsonSerializable.php b/library/Zend/Stdlib/JsonSerializable.php deleted file mode 100644 index 0445f025812..00000000000 --- a/library/Zend/Stdlib/JsonSerializable.php +++ /dev/null @@ -1,28 +0,0 @@ -=5.3.3" }, - "require-dev": { - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-serializer": "self.version", - "zendframework/zend-servicemanager": "self.version" - }, - "suggest": { - "zendframework/zend-eventmanager": "To support aggregate hydrator usage", - "zendframework/zend-serializer": "Zend\\Serializer component", - "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php b/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php index 569645d5c35..8afa63476bb 100644 --- a/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php +++ b/library/Zend/Tag/Cloud/Decorator/HtmlCloud.php @@ -20,7 +20,7 @@ class HtmlCloud extends AbstractCloud * @var array */ protected $htmlTags = array( - 'ul' => array('class' => 'zend-tag-cloud'), + 'ul' => array('class' => 'Zend\Tag\Cloud') ); /** diff --git a/library/Zend/Tag/composer.json b/library/Zend/Tag/composer.json index d256f043de8..45900c0988c 100644 --- a/library/Zend/Tag/composer.json +++ b/library/Zend/Tag/composer.json @@ -17,12 +17,6 @@ "zendframework/zend-escaper": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-servicemanager": "self.version" - }, - "suggest": { - "zendframework/zend-servicemanager": "Zend\\ServiceManager component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Test/composer.json b/library/Zend/Test/composer.json index 860811a51a5..926f12ba8f9 100644 --- a/library/Zend/Test/composer.json +++ b/library/Zend/Test/composer.json @@ -24,12 +24,6 @@ "zendframework/zend-uri": "self.version", "zendframework/zend-view": "self.version" }, - "require-dev": { - "zendframework/zend-console": "self.version" - }, - "suggest": { - "zendframework/zend-console": "Zend\\Console component" - }, "extra": { "branch-alias": { "dev-master": "2.2-dev", diff --git a/library/Zend/Validator/NotEmpty.php b/library/Zend/Validator/NotEmpty.php index c84cb37d282..99da975c8a1 100644 --- a/library/Zend/Validator/NotEmpty.php +++ b/library/Zend/Validator/NotEmpty.php @@ -47,21 +47,6 @@ class NotEmpty extends AbstractValidator self::ALL => 'all', ); - /** - * Default value for types; value = 493 - * - * @var array - */ - protected $defaultType = array( - self::OBJECT, - self::SPACE, - self::NULL, - self::EMPTY_ARRAY, - self::STRING, - self::FLOAT, - self::BOOLEAN - ); - /** * @var array */ @@ -75,7 +60,9 @@ class NotEmpty extends AbstractValidator * * @var array */ - protected $options = array(); + protected $options = array( + 'type' => 493, // Internal type to detect + ); /** * Constructor @@ -84,8 +71,6 @@ class NotEmpty extends AbstractValidator */ public function __construct($options = null) { - $this->setType($this->defaultType); - if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } @@ -131,18 +116,13 @@ public function getType() } /** - * @return int - */ - public function getDefaultType() - { - return $this->calculateTypeValue($this->defaultType); - } - - /** - * @param array|int|string $type - * @return int + * Set the types + * + * @param int|array $type + * @throws Exception\InvalidArgumentException + * @return NotEmpty */ - protected function calculateTypeValue($type) + public function setType($type = null) { if (is_array($type)) { $detected = 0; @@ -159,26 +139,11 @@ protected function calculateTypeValue($type) $type = array_search($type, $this->constants); } - return $type; - } - - /** - * Set the types - * - * @param int|array $type - * @throws Exception\InvalidArgumentException - * @return NotEmpty - */ - public function setType($type = null) - { - $type = $this->calculateTypeValue($type); - if (!is_int($type) || ($type < 0) || ($type > self::ALL)) { throw new Exception\InvalidArgumentException('Unknown type'); } $this->options['type'] = $type; - return $this; } diff --git a/library/Zend/Validator/composer.json b/library/Zend/Validator/composer.json index e8dc111e1d0..165564d8d28 100644 --- a/library/Zend/Validator/composer.json +++ b/library/Zend/Validator/composer.json @@ -17,13 +17,10 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { - "zendframework/zend-db": "self.version", "zendframework/zend-filter": "self.version", "zendframework/zend-i18n": "self.version", "zendframework/zend-math": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-session": "self.version", - "zendframework/zend-uri": "self.version" + "zendframework/zend-servicemanager": "self.version" }, "suggest": { "zendframework/zend-db": "Zend\\Db component", @@ -31,9 +28,7 @@ "zendframework/zend-i18n": "Zend\\I18n component to allow translation of validation error messages as well as to use the various Date validators", "zendframework/zend-math": "Zend\\Math component", "zendframework/zend-resources": "Translations of validator messages", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component to allow using the ValidatorPluginManager and validator chains", - "zendframework/zend-session": "Zend\\Session component", - "zendframework/zend-uri": "Zend\\Uri component" + "zendframework/zend-servicemanager": "Zend\\ServiceManager component to allow using the ValidatorPluginManager and validator chains" }, "extra": { "branch-alias": { diff --git a/library/Zend/Version/Version.php b/library/Zend/Version/Version.php index 99be1777733..dc5073ba0bb 100644 --- a/library/Zend/Version/Version.php +++ b/library/Zend/Version/Version.php @@ -9,7 +9,6 @@ namespace Zend\Version; -use Zend\Http; use Zend\Json\Json; /** @@ -20,7 +19,7 @@ final class Version /** * Zend Framework version identification - see compareVersion() */ - const VERSION = '2.3.0dev'; + const VERSION = '2.2.3dev'; /** * Github Service Identifier for version information is retreived from @@ -53,7 +52,6 @@ public static function compareVersion($version) { $version = strtolower($version); $version = preg_replace('/(\d)pr(\d?)/', '$1a$2', $version); - return version_compare($version, strtolower(self::VERSION)); } @@ -69,158 +67,51 @@ public static function compareVersion($version) * the array to a single value, comparing the version numbers with * version_compare(). * - * @see http://developer.github.com/v3/git/refs/#get-all-references - * @link https://api.github.com/repos/zendframework/zf2/git/refs/tags/release- - * @link http://framework.zend.com/api/zf-version?v=2 - * @param string $service Version service with which to retrieve the version - * @param Http\Client $httpClient HTTP client with which to retrieve the version + * @see http://developer.github.com/v3/git/refs/#get-all-references + * @link https://api.github.com/repos/zendframework/zf2/git/refs/tags/release- + * @link http://framework.zend.com/api/zf-version?v=2 + * @param string $service Version Service with which to retrieve the version * @return string */ - public static function getLatest($service = self::VERSION_SERVICE_ZEND, Http\Client $httpClient = null) + public static function getLatest($service = self::VERSION_SERVICE_ZEND) { - if (null !== self::$latestVersion) { - return self::$latestVersion; - } - - self::$latestVersion = 'not available'; - - if (null === $httpClient && !ini_get('allow_url_fopen')) { - trigger_error( - sprintf( - 'allow_url_fopen is not set, and no Zend\Http\Client ' . - 'was passed. You must either set allow_url_fopen in ' . - 'your PHP configuration or pass a configured ' . - 'Zend\Http\Client as the second argument to %s.', - __METHOD__ - ), - E_USER_WARNING - ); - - return self::$latestVersion; + if (null === static::$latestVersion) { + static::$latestVersion = 'not available'; + if ($service == self::VERSION_SERVICE_GITHUB) { + $url = 'https://api.github.com/repos/zendframework/zf2/git/refs/tags/release-'; + + $apiResponse = Json::decode(file_get_contents($url), Json::TYPE_ARRAY); + + // Simplify the API response into a simple array of version numbers + $tags = array_map(function ($tag) { + return substr($tag['ref'], 18); // Reliable because we're filtering on 'refs/tags/release-' + }, $apiResponse); + + // Fetch the latest version number from the array + static::$latestVersion = array_reduce($tags, function ($a, $b) { + return version_compare($a, $b, '>') ? $a : $b; + }); + } elseif ($service == self::VERSION_SERVICE_ZEND) { + $handle = fopen('http://framework.zend.com/api/zf-version?v=2', 'r'); + if (false !== $handle) { + static::$latestVersion = stream_get_contents($handle); + fclose($handle); + } + } } - $response = false; - if ($service === self::VERSION_SERVICE_GITHUB) { - $response = self::getLatestFromGithub($httpClient); - } elseif ($service === self::VERSION_SERVICE_ZEND) { - $response = self::getLatestFromZend($httpClient); - } else { - trigger_error( - sprintf( - 'Unknown version service: %s', - $service - ), - E_USER_WARNING - ); - } - - if ($response) { - self::$latestVersion = $response; - } - - return self::$latestVersion; + return static::$latestVersion; } /** * Returns true if the running version of Zend Framework is * the latest (or newer??) than the latest tag on GitHub, - * which is returned by self::getLatest(). + * which is returned by static::getLatest(). * * @return bool */ public static function isLatest() { - return self::compareVersion(self::getLatest()) < 1; - } - - /** - * Get the API response to a call from a configured HTTP client - * - * @param Http\Client $httpClient Configured HTTP client - * @return string|false API response or false on error - */ - protected static function getApiResponse(Http\Client $httpClient) - { - try { - $response = $httpClient->send(); - } catch (Http\Exception\RuntimeException $e) { - return false; - } - - if (!$response->isSuccess()) { - return false; - } - - return $response->getBody(); - } - - /** - * Get the latest version from Github - * - * @param Http\Client $httpClient Configured HTTP client - * @return string|null API response or false on error - */ - protected static function getLatestFromGithub(Http\Client $httpClient = null) - { - $url = 'https://api.github.com/repos/zendframework/zf2/git/refs/tags/release-'; - - if ($httpClient === null) { - $context = stream_context_create( - array( - 'http' => array( - 'user_agent' => sprintf('Zend-Version/%s', self::VERSION), - ), - ) - ); - $apiResponse = file_get_contents($url, false, $context); - } else { - $request = new Http\Request(); - $request->setUri($url); - $httpClient->setRequest($request); - $apiResponse = self::getApiResponse($httpClient); - } - - if (!$apiResponse) { - return false; - } - - $decodedResponse = Json::decode($apiResponse, Json::TYPE_ARRAY); - - // Simplify the API response into a simple array of version numbers - $tags = array_map(function ($tag) { - return substr($tag['ref'], 18); // Reliable because we're - // filtering on 'refs/tags/release-' - }, $decodedResponse); - - // Fetch the latest version number from the array - return array_reduce($tags, function ($a, $b) { - return version_compare($a, $b, '>') ? $a : $b; - }); - } - - /** - * Get the latest version from framework.zend.com - * - * @param Http\Client $httpClient Configured HTTP client - * @return string|null API response or false on error - */ - protected static function getLatestFromZend(Http\Client $httpClient = null) - { - $url = 'http://framework.zend.com/api/zf-version?v=2'; - - if ($httpClient === null) { - $apiResponse = file_get_contents($url); - } else { - $request = new Http\Request(); - $request->setUri($url); - $httpClient->setRequest($request); - $apiResponse = self::getApiResponse($httpClient); - } - - if (!$apiResponse) { - return false; - } - - return $apiResponse; + return static::compareVersion(static::getLatest()) < 1; } } diff --git a/library/Zend/Version/composer.json b/library/Zend/Version/composer.json index aa32fba6390..9059e2799dd 100644 --- a/library/Zend/Version/composer.json +++ b/library/Zend/Version/composer.json @@ -13,11 +13,7 @@ }, "target-dir": "Zend/Version", "require": { - "php": ">=5.3.3", - "zendframework/zend-json": "self.version" - }, - "suggest": { - "zendframework/zend-http": "Allows use of Zend\\Http\\Client to check version information" + "php": ">=5.3.3" }, "extra": { "branch-alias": { diff --git a/library/Zend/View/Helper/FlashMessenger.php b/library/Zend/View/Helper/FlashMessenger.php index d15b6adcc22..7e71fcca797 100644 --- a/library/Zend/View/Helper/FlashMessenger.php +++ b/library/Zend/View/Helper/FlashMessenger.php @@ -31,7 +31,6 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA PluginFlashMessenger::NAMESPACE_ERROR => 'error', PluginFlashMessenger::NAMESPACE_SUCCESS => 'success', PluginFlashMessenger::NAMESPACE_DEFAULT => 'default', - PluginFlashMessenger::NAMESPACE_WARNING => 'warning', ); /** diff --git a/library/Zend/View/Helper/HeadLink.php b/library/Zend/View/Helper/HeadLink.php index ca4ec6f5c4c..872cc669e5e 100644 --- a/library/Zend/View/Helper/HeadLink.php +++ b/library/Zend/View/Helper/HeadLink.php @@ -304,11 +304,7 @@ public function itemToString(stdClass $item) && !empty($attributes['conditionalStylesheet']) && is_string($attributes['conditionalStylesheet'])) { - // inner wrap with comment end and start if !IE - if (str_replace(' ', '', $attributes['conditionalStylesheet']) === '!IE') { - $link = '' . $link . ''; + $link = ''; } return $link; diff --git a/library/Zend/View/Helper/HeadMeta.php b/library/Zend/View/Helper/HeadMeta.php index 97c65333beb..4feecd79495 100644 --- a/library/Zend/View/Helper/HeadMeta.php +++ b/library/Zend/View/Helper/HeadMeta.php @@ -269,10 +269,6 @@ public function itemToString(stdClass $item) && !empty($item->modifiers['conditional']) && is_string($item->modifiers['conditional'])) { - // inner wrap with comment end and start if !IE - if (str_replace(' ', '', $item->modifiers['conditional']) === '!IE') { - $meta = '' . $meta . ''; } diff --git a/library/Zend/View/Helper/HeadScript.php b/library/Zend/View/Helper/HeadScript.php index 3b2bc916019..f2bea24a3f3 100644 --- a/library/Zend/View/Helper/HeadScript.php +++ b/library/Zend/View/Helper/HeadScript.php @@ -408,10 +408,6 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) && !empty($item->attributes['conditional']) && is_string($item->attributes['conditional'])) { - // inner wrap with comment end and start if !IE - if (str_replace(' ', '', $item->attributes['conditional']) === '!IE') { - $html = '' . $html . ''; } else { $html = $indent . $html; diff --git a/library/Zend/View/Helper/HeadStyle.php b/library/Zend/View/Helper/HeadStyle.php index 8deef8a1c9b..fa81431e1d4 100644 --- a/library/Zend/View/Helper/HeadStyle.php +++ b/library/Zend/View/Helper/HeadStyle.php @@ -333,11 +333,7 @@ public function itemToString(stdClass $item, $indent) . ''; if (null == $escapeStart && null == $escapeEnd) { - // inner wrap with comment end and start if !IE - if (str_replace(' ', '', $item->attributes['conditional']) === '!IE') { - $html = '' . $html . ''; + $html = ''; } return $html; diff --git a/library/Zend/View/composer.json b/library/Zend/View/composer.json index 390d9205112..d61c03a81ce 100644 --- a/library/Zend/View/composer.json +++ b/library/Zend/View/composer.json @@ -18,35 +18,9 @@ "zendframework/zend-loader": "self.version", "zendframework/zend-stdlib": "self.version" }, - "require-dev": { - "zendframework/zend-authentication": "self.version", - "zendframework/zend-escaper": "self.version", - "zendframework/zend-feed": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-http": "self.version", - "zendframework/zend-i18n": "self.version", - "zendframework/zend-json": "self.version", - "zendframework/zend-mvc": "self.version", - "zendframework/zend-navigation": "self.version", - "zendframework/zend-paginator": "self.version", - "zendframework/zend-permissions-acl": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-uri": "self.version" - }, "suggest": { - "zendframework/zend-authentication": "Zend\\Authentication component", - "zendframework/zend-escaper": "Zend\\Escaper component", - "zendframework/zend-feed": "Zend\\Feed component", "zendframework/zend-filter": "Zend\\Filter component", - "zendframework/zend-http": "Zend\\Http component", - "zendframework/zend-i18n": "Zend\\I18n component", - "zendframework/zend-json": "Zend\\Json component", - "zendframework/zend-mvc": "Zend\\Mvc component", - "zendframework/zend-navigation": "Zend\\Navigation component", - "zendframework/zend-paginator": "Zend\\Paginator component", - "zendframework/zend-permissions-acl": "Zend\\Permissions\\Acl component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-uri": "Zend\\Uri component" + "zendframework/zend-servicemanager": "self.version" }, "extra": { "branch-alias": { diff --git a/tests/ZendTest/Authentication/Adapter/HttpTest.php b/tests/ZendTest/Authentication/Adapter/HttpTest.php deleted file mode 100644 index 1eed094591f..00000000000 --- a/tests/ZendTest/Authentication/Adapter/HttpTest.php +++ /dev/null @@ -1,52 +0,0 @@ - 'basic', - 'realm' => 'testing', - ); - - $this->_wrapper = new Wrapper($config); - } - - public function tearDown() - { - unset($this->_wrapper); - } - - /** - * @expectedException PHPUnit_Framework_Error_Deprecated - */ - public function testProtectedMethodChallengeClientTriggersErrorDeprecated() - { - $this->_wrapper->_challengeClient(); - } -} - -class Wrapper extends Adapter\Http -{ - public function __call($method, $args) - { - return call_user_func_array(array($this, $method), $args); - } -} diff --git a/tests/ZendTest/Cache/Storage/Adapter/BlackHoleTest.php b/tests/ZendTest/Cache/Storage/Adapter/BlackHoleTest.php deleted file mode 100644 index f01bc75f1bd..00000000000 --- a/tests/ZendTest/Cache/Storage/Adapter/BlackHoleTest.php +++ /dev/null @@ -1,155 +0,0 @@ -storage = StorageFactory::adapterFactory('BlackHole'); - } - - public function testGetOptions() - { - $options = $this->storage->getOptions(); - $this->assertInstanceOf('Zend\Cache\Storage\Adapter\AdapterOptions', $options); - } - - public function testSetOptions() - { - $this->storage->setOptions(array('namespace' => 'test')); - $this->assertSame('test', $this->storage->getOptions()->getNamespace()); - } - - public function testGetCapabilities() - { - $capabilities = $this->storage->getCapabilities(); - $this->assertInstanceOf('Zend\Cache\Storage\Capabilities', $capabilities); - } - - public function testSingleStorageOperatios() - { - $this->assertFalse($this->storage->setItem('test', 1)); - $this->assertFalse($this->storage->addItem('test', 1)); - $this->assertFalse($this->storage->replaceItem('test', 1)); - $this->assertFalse($this->storage->touchItem('test')); - $this->assertFalse($this->storage->incrementItem('test', 1)); - $this->assertFalse($this->storage->decrementItem('test', 1)); - $this->assertFalse($this->storage->hasItem('test')); - $this->assertNull($this->storage->getItem('test', $success)); - $this->assertFalse($success); - $this->assertFalse($this->storage->getMetadata('test')); - $this->assertFalse($this->storage->removeItem('test')); - } - - public function testMultiStorageOperatios() - { - $this->assertSame(array('test'), $this->storage->setItems(array('test' => 1))); - $this->assertSame(array('test'), $this->storage->addItems(array('test' => 1))); - $this->assertSame(array('test'), $this->storage->replaceItems(array('test' => 1))); - $this->assertSame(array('test'), $this->storage->touchItems(array('test'))); - $this->assertSame(array(), $this->storage->incrementItems(array('test' => 1))); - $this->assertSame(array(), $this->storage->decrementItems(array('test' => 1))); - $this->assertSame(array(), $this->storage->hasItems(array('test'))); - $this->assertSame(array(), $this->storage->getItems(array('test'))); - $this->assertSame(array(), $this->storage->getMetadatas(array('test'))); - $this->assertSame(array('test'), $this->storage->removeItems(array('test'))); - } - - public function testAvailableSpaceCapableInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\AvailableSpaceCapableInterface', $this->storage); - $this->assertSame(0, $this->storage->getAvailableSpace()); - } - - public function testClearByNamespaceInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\ClearByNamespaceInterface', $this->storage); - $this->assertFalse($this->storage->clearByNamespace('test')); - } - - public function testClearByPrefixInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\ClearByPrefixInterface', $this->storage); - $this->assertFalse($this->storage->clearByPrefix('test')); - } - - public function testCleariExpiredInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\ClearExpiredInterface', $this->storage); - $this->assertFalse($this->storage->clearExpired()); - } - - public function testFlushableInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\FlushableInterface', $this->storage); - $this->assertFalse($this->storage->flush()); - } - - public function testIterableInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\IterableInterface', $this->storage); - $iterator = $this->storage->getIterator(); - foreach ($iterator as $item) { - $this->fail('The iterator of the BlackHole adapter should be empty'); - } - } - - public function testOptimizableInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\OptimizableInterface', $this->storage); - $this->assertFalse($this->storage->optimize()); - } - - public function testTaggableInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\TaggableInterface', $this->storage); - $this->assertFalse($this->storage->setTags('test', array('tag1'))); - $this->assertFalse($this->storage->getTags('test')); - $this->assertFalse($this->storage->clearByTags(array('tag1'))); - } - - public function testTotalSpaceCapableInterface() - { - $this->assertInstanceOf('Zend\Cache\Storage\TotalSpaceCapableInterface', $this->storage); - $this->assertSame(0, $this->storage->getTotalSpace()); - } -} diff --git a/tests/ZendTest/Cache/StorageFactoryTest.php b/tests/ZendTest/Cache/StorageFactoryTest.php index 610006a728c..febf526bac9 100644 --- a/tests/ZendTest/Cache/StorageFactoryTest.php +++ b/tests/ZendTest/Cache/StorageFactoryTest.php @@ -135,16 +135,6 @@ public function testFactoryWithPlugins() } } - public function testFactoryInstantiateAdapterWithPluginsWithoutEventsCapableInterfaceThrowsException() - { - // The BlackHole adapter doesn't implement EventsCapableInterface - $this->setExpectedException('Zend\Cache\Exception\RuntimeException'); - Cache\StorageFactory::factory(array( - 'adapter' => 'blackhole', - 'plugins' => array('Serializer'), - )); - } - public function testFactoryWithPluginsAndOptionsArray() { $factory = array( diff --git a/tests/ZendTest/Config/FactoryTest.php b/tests/ZendTest/Config/FactoryTest.php index a66935fa368..fa03b44ae00 100644 --- a/tests/ZendTest/Config/FactoryTest.php +++ b/tests/ZendTest/Config/FactoryTest.php @@ -17,7 +17,6 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { protected $tmpFiles = array(); - protected $originalIncludePath; protected function getTestAssetFileName($ext) { @@ -27,16 +26,8 @@ protected function getTestAssetFileName($ext) return $this->tmpfiles[$ext]; } - public function setUp() - { - $this->originalIncludePath = get_include_path(); - set_include_path(__DIR__ . '/TestAssets'); - } - public function tearDown() { - set_include_path($this->originalIncludePath); - foreach ($this->tmpFiles as $file) { if (file_exists($file)) { if (!is_writable($file)) { @@ -111,20 +102,6 @@ public function testFromIniAndXmlAndPhpFiles() $this->assertEquals('baz', $config['last']['bar']); } - public function testFromIniAndXmlAndPhpFilesFromIncludePath() - { - $files = array ( - 'Ini/include-base.ini', - 'Xml/include-base2.xml', - 'Php/include-base3.php', - ); - $config = Factory::fromFiles($files, false, true); - - $this->assertEquals('bar', $config['base']['foo']); - $this->assertEquals('baz', $config['test']['bar']); - $this->assertEquals('baz', $config['last']['bar']); - } - public function testReturnsConfigObjectIfRequestedAndArrayOtherwise() { $files = array ( diff --git a/tests/ZendTest/Config/Reader/JavaPropertiesTest.php b/tests/ZendTest/Config/Reader/JavaPropertiesTest.php deleted file mode 100644 index f585ef73d10..00000000000 --- a/tests/ZendTest/Config/Reader/JavaPropertiesTest.php +++ /dev/null @@ -1,79 +0,0 @@ -reader = new JavaProperties(); - } - - /** - * getTestAssetPath(): defined by AbstractReaderTestCase. - * - * @see AbstractReaderTestCase::getTestAssetPath() - * @return string - */ - protected function getTestAssetPath($name) - { - return __DIR__ . '/TestAssets/JavaProperties/' . $name . '.properties'; - } - - public function testFromFile() - { - $arrayJavaProperties = $this->reader->fromFile($this->getTestAssetPath('include-target')); - - $this->assertNotEmpty($arrayJavaProperties); - $this->assertEquals($arrayJavaProperties['single.line'], 'test'); - $this->assertEquals($arrayJavaProperties['multiple'], 'line test'); - } - - public function testIncludeAsElement() - { - $arrayJavaProperties = $this->reader->fromFile($this->getTestAssetPath('include-base')); - - $this->assertNotEmpty($arrayJavaProperties); - $this->assertEquals($arrayJavaProperties['single.line'], 'test'); - $this->assertEquals($arrayJavaProperties['multiple'], 'line test'); - } - - public function testFromString() - { - $JavaProperties = <<<'ASSET' -#comment -!comment -single.line:test -multiple:line \ -test -ASSET; - - $arrayJavaProperties = $this->reader->fromString($JavaProperties); - - $this->assertNotEmpty($arrayJavaProperties); - $this->assertEquals($arrayJavaProperties['single.line'], 'test'); - $this->assertEquals($arrayJavaProperties['multiple'], 'line test'); - } - - public function testInvalidIncludeInString() - { - $JavaProperties = '@include:fail.properties'; - - $expectedErrorMessage = 'Cannot process @include statement for a string'; - - $this->setExpectedException('Zend\Config\Exception\RuntimeException', $expectedErrorMessage); - $arrayJavaPropterties = $this->reader->fromString($JavaProperties); - } -} diff --git a/tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-base.properties b/tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-base.properties deleted file mode 100644 index a2cdfbfa30d..00000000000 --- a/tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-base.properties +++ /dev/null @@ -1,3 +0,0 @@ -#comment -!comment -@include:include-target.properties diff --git a/tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-target.properties b/tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-target.properties deleted file mode 100644 index e0813555977..00000000000 --- a/tests/ZendTest/Config/Reader/TestAssets/JavaProperties/include-target.properties +++ /dev/null @@ -1,3 +0,0 @@ -single.line:test -multiple:line \ -test diff --git a/tests/ZendTest/Console/Adapter/AbstractAdapterTest.php b/tests/ZendTest/Console/Adapter/AbstractAdapterTest.php index 4a12888258f..06e0946c0e1 100644 --- a/tests/ZendTest/Console/Adapter/AbstractAdapterTest.php +++ b/tests/ZendTest/Console/Adapter/AbstractAdapterTest.php @@ -7,7 +7,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ -namespace ZendTest\Console\Adapter; +namespace ZendTest\Console\Adapater; use ZendTest\Console\TestAssets\ConsoleAdapter; @@ -120,28 +120,4 @@ public function testReadCharWithMaskInsensitiveCase() $char = $this->adapter->readChar('ar'); $this->assertEquals($char, 'r'); } - - public function testEncodeText() - { - //Utf8 string - $text = '\u00E9\u00E9\u00E9'; - - //Console UTF8 - Text utf8 - $this->adapter->setTestUtf8(true); - $encodedText = $this->adapter->encodeText($text); - $this->assertEquals($text,$encodedText); - - //Console UTF8 - Text not utf8 - $encodedText = $this->adapter->encodeText(utf8_decode($text)); - $this->assertEquals($text,$encodedText); - - //Console not UTF8 - Text utf8 - $this->adapter->setTestUtf8(false); - $encodedText = $this->adapter->encodeText($text); - $this->assertEquals(utf8_decode($text),$encodedText); - - //Console not UTF8 - Text not utf8 - $encodedText = $this->adapter->encodeText(utf8_decode($text)); - $this->assertEquals(utf8_decode($text),$encodedText); - } } diff --git a/tests/ZendTest/Console/RouteMatcher/DefaultRouteMatcherTest.php b/tests/ZendTest/Console/RouteMatcher/DefaultRouteMatcherTest.php deleted file mode 100644 index 2fde5dd5165..00000000000 --- a/tests/ZendTest/Console/RouteMatcher/DefaultRouteMatcherTest.php +++ /dev/null @@ -1,1308 +0,0 @@ - array( - '--foo --bar', - array('a','b','--baz'), - null - ), - 'mandatory-long-flag-no-partial-match' => array( - '--foo --bar', - array('--foo','--baz'), - null - ), - 'mandatory-long-flag-match' => array( - '--foo --bar', - array('--foo','--bar'), - array('foo' => true, 'bar' => true) - ), - 'mandatory-long-flag-match-with-zero-value' => array( - '--foo=', - array('--foo=0'), - array('foo' => 0) - ), - 'mandatory-long-flag-mixed-order-match' => array( - '--foo --bar', - array('--bar','--foo'), - array('foo' => true, 'bar' => true) - ), - 'mandatory-long-flag-whitespace-in-definition' => array( - ' --foo --bar ', - array('--bar','--foo'), - array( - 'foo' => true, - 'bar' => true, - 'baz' => null, - ) - ), - 'mandatory-long-flag-alternative1' => array( - ' ( --foo | --bar )', - array('--foo'), - array( - 'foo' => true, - 'bar' => false, - 'baz' => null, - ) - ), - 'mandatory-long-flag-alternative2' => array( - ' ( --foo | --bar )', - array('--bar'), - array( - 'foo' => false, - 'bar' => true, - 'baz' => null, - ) - ), - 'mandatory-long-flag-alternative3' => array( - ' ( --foo | --bar )', - array('--baz'), - null - ), - - // -- mandatory short flags - 'mandatory-short-flag-no-match' => array( - '-f -b', - array('a','b','-f'), - null - ), - 'mandatory-short-flag-no-partial-match' => array( - '-f -b', - array('-f','-z'), - null - ), - 'mandatory-short-flag-match' => array( - '-f -b', - array('-f','-b'), - array('f' => true, 'b' => true) - ), - 'mandatory-short-flag-mixed-order-match' => array( - '-f -b', - array('-b','-f'), - array('f' => true, 'b' => true) - ), - 'mandatory-short-flag-whitespace-in-definition' => array( - ' -f -b ', - array('-b','-f'), - array( - 'f' => true, - 'b' => true, - 'baz' => null, - ) - ), - 'mandatory-short-flag-alternative1' => array( - ' ( -f | -b )', - array('-f'), - array( - 'f' => true, - 'b' => false, - 'baz' => null, - ) - ), - 'mandatory-short-flag-alternative2' => array( - ' ( -f | -b )', - array('-b'), - array( - 'f' => false, - 'b' => true, - 'baz' => null, - ) - ), - 'mandatory-short-flag-alternative3' => array( - ' ( -f | -b )', - array('--baz'), - null - ), - - // -- optional long flags - 'optional-long-flag-non-existent' => array( - '--foo [--bar]', - array('--foo'), - array( - 'foo' => true, - 'bar' => null, - 'baz' => null, - ) - ), - 'literal-optional-long-flag' => array( - 'foo [--bar]', - array('foo', '--bar'), - array( - 'foo' => null, - 'bar' => true, - ) - ), - 'optional-long-flag-partial-mismatch' => array( - '--foo [--bar]', - array('--foo', '--baz'), - null - ), - 'optional-long-flag-match' => array( - '--foo [--bar]', - array('--foo','--bar'), - array( - 'foo' => true, - 'bar' => true - ) - ), - 'optional-long-value-flag-non-existent' => array( - '--foo [--bar=]', - array('--foo'), - array( - 'foo' => true, - 'bar' => false - ) - ), - 'optional-long-flag-match-with-zero-value' => array( - '[--foo=]', - array('--foo=0'), - array('foo' => 0) - ), - 'optional-long-value-flag' => array( - '--foo [--bar=]', - array('--foo', '--bar=4'), - array( - 'foo' => true, - 'bar' => 4 - ) - ), - 'optional-long-value-flag-non-existent-mixed-case' => array( - '--foo [--barBaz=]', - array('--foo', '--barBaz=4'), - array( - 'foo' => true, - 'barBaz' => 4 - ) - ), - 'value-optional-long-value-flag' => array( - ' [--bar=]', - array('value', '--bar=4'), - array( - 'foo' => 'value', - 'bar' => 4 - ) - ), - 'literal-optional-long-value-flag' => array( - 'foo [--bar=]', - array('foo', '--bar=4'), - array( - 'foo' => null, - 'bar' => 4, - ) - ), - 'optional-long-flag-mixed-order-match' => array( - '--foo --bar', - array('--bar','--foo'), - array('foo' => true, 'bar' => true) - ), - 'optional-long-flag-whitespace-in-definition' => array( - ' --foo [--bar] ', - array('--bar','--foo'), - array( - 'foo' => true, - 'bar' => true, - 'baz' => null, - ) - ), - 'optional-long-flag-whitespace-in-definition2' => array( - ' --foo [--bar ] ', - array('--bar','--foo'), - array( - 'foo' => true, - 'bar' => true, - 'baz' => null, - ) - ), - 'optional-long-flag-whitespace-in-definition3' => array( - ' --foo [ --bar ] ', - array('--bar','--foo'), - array( - 'foo' => true, - 'bar' => true, - 'baz' => null, - ) - ), - - - // -- value flags - 'mandatory-value-flag-syntax-1' => array( - '--foo=s', - array('--foo','bar'), - array( - 'foo' => 'bar', - 'bar' => null - ) - ), - 'mandatory-value-flag-syntax-2' => array( - '--foo=', - array('--foo','bar'), - array( - 'foo' => 'bar', - 'bar' => null - ) - ), - 'mandatory-value-flag-syntax-3' => array( - '--foo=anystring', - array('--foo','bar'), - array( - 'foo' => 'bar', - 'bar' => null - ) - ), - - // -- edge cases for value flags values - 'mandatory-value-flag-equals-complex-1' => array( - '--foo=', - array('--foo=SomeComplexValue=='), - array('foo' => 'SomeComplexValue==') - ), - 'mandatory-value-flag-equals-complex-2' => array( - '--foo=', - array('--foo=..., '..., array( - '--foo=', - array('--foo====--'), - array('foo' => '===--') - ), - 'mandatory-value-flag-space-complex-1' => array( - '--foo=', - array('--foo','SomeComplexValue=='), - array('foo' => 'SomeComplexValue==') - ), - 'mandatory-value-flag-space-complex-2' => array( - '--foo=', - array('--foo','..., '..., array( - '--foo=', - array('--foo','===--'), - array('foo' => '===--') - ), - - // -- required literal params - 'mandatory-literal-match-1' => array( - 'foo', - array('foo'), - array('foo' => null) - ), - 'mandatory-literal-match-2' => array( - 'foo bar baz', - array('foo','bar','baz'), - array('foo' => null, 'bar' => null, 'baz' => null, 'bazinga' => null) - ), - 'mandatory-literal-mismatch' => array( - 'foo', - array('fooo'), - null - ), - 'mandatory-literal-order' => array( - 'foo bar', - array('bar','foo'), - null - ), - 'mandatory-literal-partial-mismatch' => array( - 'foo bar baz', - array('foo','bar'), - null - ), - 'mandatory-literal-alternative-match-1' => array( - 'foo ( bar | baz )', - array('foo','bar'), - array('foo' => null, 'bar' => true, 'baz' => false) - ), - 'mandatory-literal-alternative-match-2' => array( - 'foo (bar|baz)', - array('foo','bar'), - array('foo' => null, 'bar' => true, 'baz' => false) - ), - 'mandatory-literal-alternative-match-3' => array( - 'foo ( bar | baz )', - array('foo','baz'), - array('foo' => null, 'bar' => false, 'baz' => true) - ), - 'mandatory-literal-alternative-mismatch' => array( - 'foo ( bar | baz )', - array('foo','bazinga'), - null - ), - 'mandatory-literal-namedAlternative-match-1' => array( - 'foo ( bar | baz ):altGroup', - array('foo','bar'), - array('foo' => null, 'altGroup'=>'bar', 'bar' => true, 'baz' => false) - ), - 'mandatory-literal-namedAlternative-match-2' => array( - 'foo ( bar | baz ):altGroup9', - array('foo','baz'), - array('foo' => null, 'altGroup9'=>'baz', 'bar' => false, 'baz' => true) - ), - 'mandatory-literal-namedAlternative-mismatch' => array( - 'foo ( bar | baz ):altGroup9', - array('foo','bazinga'), - null - ), - - // -- optional literal params - 'optional-literal-match' => array( - 'foo [bar] [baz]', - array('foo','bar'), - array('foo' => null, 'bar' => true, 'baz' => null) - ), - 'optional-literal-mismatch' => array( - 'foo [bar] [baz]', - array('baz','bar'), - null - ), - 'optional-literal-shuffled-mismatch' => array( - 'foo [bar] [baz]', - array('foo','baz','bar'), - null - ), - 'optional-literal-alternative-match' => array( - 'foo [bar | baz]', - array('foo','baz'), - array('foo' => null, 'baz' => true, 'bar' => false) - ), - 'optional-literal-alternative-mismatch' => array( - 'foo [bar | baz]', - array('foo'), - array('foo' => null, 'baz' => false, 'bar' => false) - ), - 'optional-literal-namedAlternative-match-1' => array( - 'foo [bar | baz]:altGroup1', - array('foo','baz'), - array('foo' => null, 'altGroup1' => 'baz', 'baz' => true, 'bar' => false) - ), - 'optional-literal-namedAlternative-match-2' => array( - 'foo [bar | baz | bazinga]:altGroup100', - array('foo','bazinga'), - array('foo' => null, 'altGroup100' => 'bazinga', 'bazinga' => true, 'baz' => false, 'bar' => false) - ), - 'optional-literal-namedAlternative-match-3' => array( - 'foo [ bar ]:altGroup100', - array('foo','bar'), - array('foo' => null, 'altGroup100' => 'bar', 'bar' => true, 'baz' => null) - ), - 'optional-literal-namedAlternative-mismatch' => array( - 'foo [ bar | baz ]:altGroup9', - array('foo'), - array('foo' => null, 'altGroup9'=> null, 'bar' => false, 'baz' => false) - ), - - // -- value params - 'mandatory-value-param-syntax-1' => array( - 'FOO', - array('bar'), - array( - 'foo' => 'bar', - 'bar' => null - ) - ), - 'mandatory-value-param-syntax-2' => array( - '', - array('bar'), - array( - 'foo' => 'bar', - 'bar' => null - ) - ), - 'mandatory-value-param-mixed-with-literal' => array( - 'a b c', - array('a','b','bar','c'), - array( - 'a' => null, - 'b' => null, - 'foo' => 'bar', - 'bar' => null, - 'c' => null, - ), - ), - 'optional-value-param-1' => array( - 'a b []', - array('a','b','bar'), - array( - 'a' => null, - 'b' => null, - 'c' => 'bar', - 'bar' => null, - ), - ), - 'optional-value-param-2' => array( - 'a b []', - array('a','b'), - array( - 'a' => null, - 'b' => null, - 'c' => null, - 'bar' => null, - ), - ), - 'optional-value-param-3' => array( - 'a b []', - array('a','b','--c'), - null - ), - - // -- combinations - 'mandatory-long-short-alternative-1' => array( - ' ( --foo | -f )', - array('--foo'), - array( - 'foo' => true, - 'f' => false, - 'baz' => null, - ) - ), - 'mandatory-long-short-alternative-2' => array( - ' ( --foo | -f )', - array('-f'), - array( - 'foo' => false, - 'f' => true, - 'baz' => null, - ) - ), - 'optional-long-short-alternative-1' => array( - 'a [ --foo | -f ]', - array('a','bar'), - array( - 'a' => null, - 'b' => 'bar', - 'foo' => false, - 'f' => false, - 'baz' => null, - ) - ), - 'optional-long-short-alternative-2' => array( - 'a [ --foo | -f ]', - array('a','bar', '-f'), - array( - 'a' => null, - 'b' => 'bar', - 'foo' => false, - 'f' => true, - 'baz' => null, - ) - ), - 'optional-long-short-alternative-3' => array( - 'a [ --foo | -f ]', - array('a','--foo', 'bar'), - array( - 'a' => null, - 'b' => 'bar', - 'foo' => true, - 'f' => false, - 'baz' => null, - ) - ), - - - 'mandatory-and-optional-value-params-with-flags-1' => array( - 'a b [] [--eee|-e] [--fff|-f]', - array('a','b','foo','bar'), - array( - 'a' => null, - 'b' => null, - 'c' => 'foo', - 'd' => 'bar', - 'e' => false, - 'eee' => false, - 'fff' => false, - 'f' => false, - ), - ), - 'mandatory-and-optional-value-params-with-flags-2' => array( - 'a b [] [--eee|-e] [--fff|-f]', - array('a','b','--eee', 'foo','bar'), - array( - 'a' => null, - 'b' => null, - 'c' => 'foo', - 'd' => 'bar', - 'e' => false, - 'eee' => true, - 'fff' => false, - 'f' => false, - ), - ), - - - // -- overflows - 'too-many-arguments1' => array( - 'foo bar', - array('foo','bar','baz'), - null - ), - 'too-many-arguments2' => array( - 'foo bar [baz]', - array('foo','bar','baz','woo'), - null, - ), - 'too-many-arguments3' => array( - 'foo bar [--baz]', - array('foo','bar','--baz','woo'), - null, - ), - 'too-many-arguments4' => array( - 'foo bar [--baz] woo', - array('foo','bar','woo'), - array( - 'foo' => null, - 'bar' => null, - 'baz' => false, - 'woo' => null - ) - ), - 'too-many-arguments5' => array( - '--foo --bar [--baz] woo', - array('--bar','--foo','woo'), - array( - 'foo' => true, - 'bar' => true, - 'baz' => false, - 'woo' => null - ) - ), - 'too-many-arguments6' => array( - '--foo --bar [--baz]', - array('--bar','--foo','woo'), - null - ), - - // other (combination) - 'combined-1' => array( - 'literal [--foo=] --baz', - array('literal', 'oneBar', '--foo=4', '--baz'), - array( - 'literal' => null, - 'bar' => 'oneBar', - 'foo' => 4, - 'baz' => true - ) - ), - // group with group name diferent than options (short) - 'group-1' => array( - 'group [-t|--test]:testgroup', - array('group', '-t'), - array( - 'group' => null, - 'testgroup' => true, - ) - ), - // group with group name diferent than options (long) - 'group-2' => array( - 'group [-t|--test]:testgroup', - array('group', '--test'), - array( - 'group' => null, - 'testgroup' => true, - ) - ), - // group with same name as option (short) - 'group-3' => array( - 'group [-t|--test]:test', - array('group', '-t'), - array( - 'group' => null, - 'test' => true, - ) - ), - // group with same name as option (long) - 'group-4' => array( - 'group [-t|--test]:test', - array('group', '--test'), - array( - 'group' => null, - 'test' => true, - ) - ), - 'group-5' => array( - 'group (-t | --test ):test', - array('group', '--test'), - array( - 'group' => null, - 'test' => true, - ), - ), - 'group-6' => array( - 'group (-t | --test ):test', - array('group', '-t'), - array( - 'group' => null, - 'test' => true, - ), - ), - 'group-7' => array( - 'group [-x|-y|-z]:test', - array('group', '-y'), - array( - 'group' => null, - 'test' => true, - ), - ), - 'group-8' => array( - 'group [--foo|--bar|--baz]:test', - array('group', '--foo'), - array( - 'group' => null, - 'test' => true, - ), - ), - 'group-9' => array( - 'group (--foo|--bar|--baz):test', - array('group', '--foo'), - array( - 'group' => null, - 'test' => true, - ), - ), - - /** - * @bug ZF2-4315 - * @link https://github.com/zendframework/zf2/issues/4315 - */ - 'literal-with-dashes' => array( - 'foo-bar-baz [--bar=]', - array('foo-bar-baz',), - array( - 'foo-bar-baz' => null, - 'foo' => null, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - - 'literal-optional-with-dashes' => array( - '[foo-bar-baz] [--bar=]', - array('foo-bar-baz'), - array( - 'foo-bar-baz' => true, - 'foo' => null, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-with-dashes2' => array( - 'foo [foo-bar-baz] [--bar=]', - array('foo'), - array( - 'foo-bar-baz' => false, - 'foo' => null, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-alternative-with-dashes' => array( - '(foo-bar|foo-baz) [--bar=]', - array('foo-bar',), - array( - 'foo-bar' => true, - 'foo-baz' => false, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-alternative-with-dashes' => array( - '[foo-bar|foo-baz] [--bar=]', - array('foo-baz',), - array( - 'foo-bar' => false, - 'foo-baz' => true, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-alternative-with-dashes2' => array( - 'foo [foo-bar|foo-baz] [--bar=]', - array('foo',), - array( - 'foo' => null, - 'foo-bar' => false, - 'foo-baz' => false, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-flag-with-dashes' => array( - 'foo --bar-baz', - array('foo','--bar-baz'), - array( - 'foo' => null, - 'bar-baz' => true, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-flag-with-dashes' => array( - 'foo [--bar-baz]', - array('foo','--bar-baz'), - array( - 'foo' => null, - 'bar-baz' => true, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-flag-with-dashes2' => array( - 'foo [--bar-baz]', - array('foo'), - array( - 'foo' => null, - 'bar-baz' => false, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-flag-alternative-with-dashes' => array( - 'foo [--foo-bar|--foo-baz]', - array('foo','--foo-baz'), - array( - 'foo' => null, - 'foo-bar' => false, - 'foo-baz' => true, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'literal-optional-flag-alternative-with-dashes2' => array( - 'foo [--foo-bar|--foo-baz]', - array('foo'), - array( - 'foo' => null, - 'foo-bar' => false, - 'foo-baz' => false, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'value-with-dashes' => array( - ' [--bar=]', - array('abc',), - array( - 'foo-bar-baz' => 'abc', - 'foo' => null, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - - 'value-optional-with-dashes' => array( - '[] [--bar=]', - array('abc'), - array( - 'foo-bar-baz' => 'abc', - 'foo' => null, - 'bar' => null, - 'baz' => null, - 'something' => null, - ) - ), - 'value-optional-with-dashes2' => array( - '[] [--bar=]', - array('--bar','abc'), - array( - 'foo-bar-baz' => null, - 'foo' => null, - 'bar' => 'abc', - 'baz' => null, - 'something' => null, - ) - ), - - - ); - } - - /** - * @dataProvider routeProvider - * @param string $routeDefinition - * @param array $arguments - * @param array|null $params - */ - public function testMatching($routeDefinition, array $arguments = array(), array $params = null) - { - $route = new DefaultRouteMatcher($routeDefinition); - $match = $route->match($arguments); - - - if ($params === null) { - $this->assertNull($match, "The route must not match"); - } else { - $this->assertInternalType('array', $match); - - foreach ($params as $key => $value) { - $this->assertEquals( - $value, - isset($match[$key])?$match[$key]:null, - $value === null ? "Param $key is not present" : "Param $key is present and is equal to $value" - ); - } - } - } - - public function testCannotMatchWithEmptyMandatoryParam() - { - $arguments = array('--foo='); - $route = new DefaultRouteMatcher('--foo='); - $match = $route->match($arguments); - $this->assertEquals(null, $match); - } - - public static function routeDefaultsProvider() - { - return array( - 'required-literals-no-defaults' => array( - 'create controller', - array(), - array('create', 'controller'), - array('create' => null, 'controller' => null), - ), - 'required-literals-defaults' => array( - 'create controller', - array('controller' => 'value'), - array('create', 'controller'), - array('create' => null, 'controller' => 'value'), - ), - 'value-param-no-defaults' => array( - 'create controller ', - array(), - array('create', 'controller', 'foo'), - array('create' => null, 'controller' => 'foo'), - ), - 'value-param-defaults-overridden' => array( - 'create controller ', - array('controller' => 'defaultValue'), - array('create', 'controller', 'foo'), - array('create' => null, 'controller' => 'foo'), - ), - 'optional-value-param-defaults' => array( - 'create controller []', - array('controller' => 'defaultValue'), - array('create', 'controller'), - array('create' => null, 'controller' => 'defaultValue'), - ), - 'alternative-literal-non-present' => array( - '(foo | bar)', - array('bar' => 'something'), - array('foo'), - array('foo' => true, 'bar' => false), - ), - 'alternative-literal-present' => array( - '(foo | bar)', - array('bar' => 'something'), - array('bar'), - array('foo' => false, 'bar' => 'something'), - ), - 'alternative-flag-non-present' => array( - '(--foo | --bar)', - array('bar' => 'something'), - array('--foo'), - array('foo' => true, 'bar' => false), - ), - 'alternative-flag-present' => array( - '(--foo | --bar)', - array('bar' => 'something'), - array('--bar'), - array('foo' => false, 'bar' => 'something'), - ), - 'optional-literal-non-present' => array( - 'foo [bar]', - array('bar' => 'something'), - array('foo'), - array('foo' => null, 'bar' => false), - ), - 'optional-literal-present' => array( - 'foo [bar]', - array('bar' => 'something'), - array('foo', 'bar'), - array('foo' => null, 'bar' => 'something'), - ), - ); - } - - /** - * @dataProvider routeDefaultsProvider - * @param string $routeDefinition - * @param array $defaults - * @param array $arguments - * @param array|null $params - */ - public function testMatchingWithDefaults( - $routeDefinition, - array $defaults = array(), - array $arguments = array(), - array $params = null - ) { - $route = new DefaultRouteMatcher($routeDefinition, array(), $defaults); - $match = $route->match($arguments); - - if ($params === null) { - $this->assertNull($match, "The route must not match"); - } else { - $this->assertInternalType('array', $match); - - foreach ($params as $key => $value) { - $this->assertSame( - $value, - isset($match[$key])?$match[$key]:null, - $value === null ? "Param $key is not present" : "Param $key is present and is equal to '$value'" - ); - } - } - } - - public static function routeConstraintsProvider() - { - return array( - 'simple-constraints' => array( - ' ', - array( - 'numeric' => '/^[0-9]+$/', - 'alpha' => '/^[a-zA-Z]+$/', - ), - array('1234', 'test'), - true - ), - 'constraints-on-optional-param' => array( - ' []', - array( - 'numeric' => '/^[0-9]+$/', - 'alpha' => '/^[a-zA-Z]+$/', - ), - array('test', '1234'), - true - ), - 'optional-empty-param' => array( - ' []', - array( - 'numeric' => '/^[0-9]+$/', - 'alpha' => '/^[a-zA-Z]+$/', - ), - array('test'), - true - ), - 'named-param' => array( - '--foo=', - array( - 'foo' => '/^bar$/' - ), - array('--foo=bar'), - true, - ), - 'failing-param' => array( - ' ', - array( - 'good1' => '/^[a-zA-Z]+$/', - 'good2' => '/^[a-zA-Z]+$/', - 'bad' => '/^[a-zA-Z]+$/', - ), - array('foo', 'bar', 'foo123bar'), - false - ), - 'failing-optional-param' => array( - ' []', - array( - 'good2' => '/^(foo|bar)$/', - 'bad' => '/^(foo|bar)$/', - ), - array('foo', 'baz'), - false - ), - 'failing-named-param' => array( - '--foo=', - array( - 'foo' => '/^bar$/' - ), - array('--foo=baz'), - false, - ), - ); - } - - /** - * @dataProvider routeConstraintsProvider - * @param string $routeDefinition - * @param array $constraints - * @param array $arguments - * @param bool $shouldMatch - */ - public function testMatchingWithConstraints( - $routeDefinition, - array $constraints = array(), - array $arguments = array(), - $shouldMatch = true - ) { - $route = new DefaultRouteMatcher($routeDefinition, $constraints); - $match = $route->match($arguments); - - if ($shouldMatch === false) { - $this->assertNull($match, "The route must not match"); - } else { - $this->assertInternalType('array', $match); - } - } - - public static function routeAliasesProvider() - { - return array( - 'simple-alias' => array( - '--user=', - array( - 'username' => 'user' - ), - array('--username=JohnDoe'), - array( - 'user' => 'JohnDoe' - ) - ), - 'multiple-aliases' => array( - '--name= --email=', - array( - 'username' => 'name', - 'useremail' => 'email' - ), - array('--username=JohnDoe', '--useremail=johndoe@domain.com'), - array( - 'name' => 'JohnDoe', - 'email' => 'johndoe@domain.com', - ) - ), - 'flags' => array( - 'foo --bar', - array( - 'baz' => 'bar' - ), - array('foo', '--baz'), - array( - 'bar' => true - ) - ), - 'with-alternatives' => array( - 'do-something (--remove|--update)', - array( - 'delete' => 'remove' - ), - array('do-something', '--delete'), - array( - 'remove' => true, - ) - ), - 'with-alternatives-2' => array( - 'do-something (--update|--remove)', - array( - 'delete' => 'remove' - ), - array('do-something', '--delete'), - array( - 'remove' => true, - ) - ) - ); - } - - /** - * @dataProvider routeAliasesProvider - * @param string $routeDefinition - * @param array $aliases - * @param array $arguments - * @param array|null $params - */ - public function testMatchingWithAliases( - $routeDefinition, - array $aliases = array(), - array $arguments = array(), - array $params = null - ) - { - $route = new DefaultRouteMatcher($routeDefinition, array(), array(), $aliases); - $match = $route->match($arguments); - - if ($params === null) { - $this->assertNull($match, "The route must not match"); - } else { - $this->assertInternalType('array', $match); - - foreach ($params as $key => $value) { - $this->assertEquals( - $value, - isset($match[$key])?$match[$key]:null, - $value === null ? "Param $key is not present" : "Param $key is present and is equal to $value" - ); - } - } - } - - public function routeValidatorsProvider() - { - return array( - 'validators-valid' => array( - ' ', - array( - 'string' => new \Zend\Validator\StringLength(array('min' => 5, 'max' => 12)), - 'number' => new \Zend\Validator\Digits() - ), - array('foobar', '12345'), - true - ), - 'validators-invalid' => array( - ' ', - array( - 'string' => new \Zend\Validator\StringLength(array('min' => 5, 'max' => 12)), - 'number' => new \Zend\Validator\Digits() - ), - array('foo', '12345'), - false - ), - 'validators-invalid2' => array( - ' ', - array( - 'string' => new \Zend\Validator\StringLength(array('min' => 5, 'max' => 12)), - 'number' => new \Zend\Validator\Digits() - ), - array('foozbar', 'not_digits'), - false - ), - - ); - } - - /** - * @dataProvider routeValidatorsProvider - * @param string $routeDefinition - * @param array $validators - * @param array $arguments - * @param bool $shouldMatch - */ - public function testParamsCanBeValidated($routeDefinition, $validators, $arguments, $shouldMatch) - { - $matcher = new DefaultRouteMatcher($routeDefinition, array(), array(), array(), null, $validators); - $match = $matcher->match($arguments); - if ($shouldMatch === false) { - $this->assertNull($match, "The route must not match"); - } else { - $this->assertInternalType('array', $match); - } - } - - public function routeFiltersProvider() - { - $genericFilter = $this->getMock('Zend\Filter\FilterInterface', array('filter')); - $genericFilter->expects($this->once())->method('filter') - ->with('foobar')->will($this->returnValue('foobaz')); - - return array( - 'filters-generic' => array( - '', - array( - 'param' => $genericFilter - ), - array('foobar'), - array( - 'param' => 'foobaz' - ) - ), - 'filters-single' => array( - '', - array( - 'number' => new \Zend\Filter\Int() - ), - array('123four'), - array( - 'number' => 123 - ) - ), - 'filters-multiple' => array( - ' ', - array( - 'number' => new \Zend\Filter\Int(), - 'strtolower' => new \Zend\Filter\StringToLower(), - ), - array('nan', 'FOOBAR'), - array( - 'number' => 0, - 'strtolower' => 'foobar' - ) - ), - ); - } - - /** - * @dataProvider routeFiltersProvider - * @param string $routeDefinition - * @param array $filters - * @param array $arguments - * @param array $params - */ - public function testParamsCanBeFiltered($routeDefinition, $filters, $arguments, $params) - { - $matcher = new DefaultRouteMatcher($routeDefinition, array(), array(), array(), $filters); - $match = $matcher->match($arguments); - - if (null === $match) { - $this->fail("Route '$routeDefinition' must match.'"); - } - - $this->assertInternalType('array', $match); - - foreach ($params as $key => $value) { - $this->assertEquals( - $value, - isset($match[$key])?$match[$key]:null, - $value === null ? "Param $key is not present" : "Param $key is present and is equal to $value" - ); - } - } - - public function testConstructorDoesNotAcceptInvalidFilters() - { - $this->setExpectedException('Zend\Console\Exception\InvalidArgumentException'); - new DefaultRouteMatcher('', array(), array(), array(), array( - new \stdClass() - )); - } - - public function testConstructorDoesNotAcceptInvalidValidators() - { - $this->setExpectedException('Zend\Console\Exception\InvalidArgumentException'); - new DefaultRouteMatcher('', array(), array(), array(), array(), array( - new \stdClass() - )); - } -} diff --git a/tests/ZendTest/Form/Element/DateSelectTest.php b/tests/ZendTest/Form/Element/DateSelectTest.php index 7811aca84dd..a62c12fcaee 100644 --- a/tests/ZendTest/Form/Element/DateSelectTest.php +++ b/tests/ZendTest/Form/Element/DateSelectTest.php @@ -62,14 +62,6 @@ public function testCanSetDateFromString() $this->assertEquals('24', $element->getDayElement()->getValue()); } - public function testCanGetValue() - { - $element = new DateSelectElement(); - $element->setValue(new DateTime('2012-09-24')); - - $this->assertEquals('2012-09-24', $element->getValue()); - } - /** * @expectedException \Zend\Form\Exception\InvalidArgumentException */ diff --git a/tests/ZendTest/Form/Element/DateTimeSelectTest.php b/tests/ZendTest/Form/Element/DateTimeSelectTest.php index bad5c019232..ef97722cdc6 100644 --- a/tests/ZendTest/Form/Element/DateTimeSelectTest.php +++ b/tests/ZendTest/Form/Element/DateTimeSelectTest.php @@ -88,14 +88,6 @@ public function testCanSetDateFromString() $this->assertEquals('05', $element->getSecondElement()->getValue()); } - public function testCanGetValue() - { - $element = new DateTimeSelectElement(); - $element->setValue(new DateTime('2012-09-24 03:04:05')); - - $this->assertEquals('2012-09-24 03:04:05', $element->getValue()); - } - /** * @expectedException \Zend\Form\Exception\InvalidArgumentException */ diff --git a/tests/ZendTest/Form/Element/MonthSelectTest.php b/tests/ZendTest/Form/Element/MonthSelectTest.php index 04f3230d97e..df7331a5ac1 100644 --- a/tests/ZendTest/Form/Element/MonthSelectTest.php +++ b/tests/ZendTest/Form/Element/MonthSelectTest.php @@ -81,11 +81,4 @@ public function testCanSetMonthFromDateTime() $this->assertEquals('2012', $element->getYearElement()->getValue()); $this->assertEquals('09', $element->getMonthElement()->getValue()); } - - public function testCanGetValue() - { - $element = new MonthSelectElement(); - $element->setValue(new DateTime('2012-09')); - $this->assertEquals('2012-09', $element->getValue()); - } } diff --git a/tests/ZendTest/Form/Element/MultiCheckboxTest.php b/tests/ZendTest/Form/Element/MultiCheckboxTest.php index 2dee9baa509..ee9523db004 100644 --- a/tests/ZendTest/Form/Element/MultiCheckboxTest.php +++ b/tests/ZendTest/Form/Element/MultiCheckboxTest.php @@ -134,18 +134,4 @@ public function testSetOptionsOptions() $this->assertEquals(array('bar' => 'baz'), $element->getOption('value_options')); $this->assertEquals(array('foo' => 'bar'), $element->getOption('options')); } - - public function testDisableInputSpecification() - { - $element = new MultiCheckboxElement(); - $element->setValueOptions(array( - 'Option 1' => 'option1', - 'Option 2' => 'option2', - 'Option 3' => 'option3', - )); - $element->setDisableInArrayValidator(true); - - $inputSpec = $element->getInputSpecification(); - $this->assertArrayNotHasKey('validators', $inputSpec); - } } diff --git a/tests/ZendTest/Form/ElementTest.php b/tests/ZendTest/Form/ElementTest.php index b40a3feb024..0509af52f83 100644 --- a/tests/ZendTest/Form/ElementTest.php +++ b/tests/ZendTest/Form/ElementTest.php @@ -159,24 +159,13 @@ public function testSpecificOptionsSetLabelAttributes() { $element = new Element('foo'); $element->setOptions(array( - 'label' => 'foo', - 'label_attributes' => array('bar' => 'baz') - )); + 'label' => 'foo', + 'label_attributes' => array('bar' => 'baz') + )); $option = $element->getOption('label_attributes'); $this->assertEquals(array('bar' => 'baz'), $option); } - public function testLabelOptionsAccessors() - { - $element = new Element('foo'); - $element->setOptions(array( - 'label_options' => array('moar' => 'foo') - )); - - $labelOptions = $element->getLabelOptions(); - $this->assertEquals(array('moar' => 'foo'), $labelOptions); - } - public function testSetOptionsWrongInputRaisesException() { $element = new Element('foo'); diff --git a/tests/ZendTest/Form/FormElementManagerTest.php b/tests/ZendTest/Form/FormElementManagerTest.php index 08b7db23ed3..14a54a8127b 100644 --- a/tests/ZendTest/Form/FormElementManagerTest.php +++ b/tests/ZendTest/Form/FormElementManagerTest.php @@ -67,46 +67,4 @@ public function testLoadingInvalidElementRaisesException() $this->setExpectedException('Zend\Form\Exception\InvalidElementException'); $this->manager->get('test'); } - - public function testStringCreationOptions() - { - $args = 'foo'; - $element = $this->manager->get('element', $args); - $this->assertEquals('foo', $element->getName(), 'The argument is string'); - } - - public function testArrayCreationOptions() - { - $args = array( - 'name' => 'foo', - 'options' => array( - 'label' => 'bar' - ), - ); - $element = $this->manager->get('element', $args); - $this->assertEquals('foo', $element->getName(), 'Specified name in array[name]'); - $this->assertEquals('bar', $element->getLabel(), 'Specified options in array[options]'); - } - - public function testOptionsCreationOptions() - { - $args = array( - 'label' => 'bar' - ); - $element = $this->manager->get('element', $args); - $this->assertEquals('element', $element->getName(), 'Invokable CNAME'); - $this->assertEquals('bar', $element->getLabel(), 'Specified options in array'); - } - - public function testArrayOptionsCreationOptions() - { - $args = array( - 'options' => array( - 'label' => 'bar' - ), - ); - $element = $this->manager->get('element', $args); - $this->assertEquals('element', $element->getName(), 'Invokable CNAME'); - $this->assertEquals('bar', $element->getLabel(), 'Specified options in array[options]'); - } } diff --git a/tests/ZendTest/Form/View/Helper/FormDateTest.php b/tests/ZendTest/Form/View/Helper/FormDateTest.php index f446995987b..4bba2270d02 100644 --- a/tests/ZendTest/Form/View/Helper/FormDateTest.php +++ b/tests/ZendTest/Form/View/Helper/FormDateTest.php @@ -50,9 +50,6 @@ public function testGeneratesInputTagRegardlessOfElementType() $this->assertContains('type="date"', $markup); } - /** - * @return array - */ public function validAttributes() { return array( @@ -128,7 +125,6 @@ public function getCompleteElement() /** * @dataProvider validAttributes - * @return void */ public function testAllValidFormMarkupAttributesPresentInElementAreRendered($attribute, $assertion) { diff --git a/tests/ZendTest/Form/View/Helper/FormInputTest.php b/tests/ZendTest/Form/View/Helper/FormInputTest.php index 773f9286359..856d99fdd61 100644 --- a/tests/ZendTest/Form/View/Helper/FormInputTest.php +++ b/tests/ZendTest/Form/View/Helper/FormInputTest.php @@ -97,9 +97,6 @@ public function testOnlyAllowsValidInputTypes($type, $assertion) $this->$assertion($expected, $markup); } - /** - * @return array - */ public function validAttributes() { return array( @@ -186,6 +183,12 @@ public function validAttributes() array('ontimeupdate', 'assertContains'), array('onvolumechange', 'assertContains'), array('onwaiting', 'assertContains'), + ); + } + + public function validAttributes2() + { + return array( array('pattern', 'assertContains'), array('placeholder', 'assertContains'), array('readonly', 'assertContains'), @@ -325,7 +328,6 @@ public function getCompleteElement() /** * @dataProvider validAttributes - * @return void */ public function testAllValidFormMarkupAttributesPresentInElementAreRendered($attribute, $assertion) { @@ -342,6 +344,27 @@ public function testAllValidFormMarkupAttributesPresentInElementAreRendered($att $this->$assertion($expect, $markup); } + /** + * Split into 2 as 5.3.3 was segfaulting, and the segfault appears to be due + * to number of items in the data provider. + * + * @dataProvider validAttributes2 + */ + public function testAllValidFormMarkupAttributesPresentInElementAreRendered2($attribute, $assertion) + { + $element = $this->getCompleteElement(); + $markup = $this->helper->render($element); + switch ($attribute) { + case 'value': + $expect = sprintf('%s="%s"', $attribute, $element->getValue()); + break; + default: + $expect = sprintf('%s="%s"', $attribute, $element->getAttribute($attribute)); + break; + } + $this->$assertion($expect, $markup); + } + public function nonXhtmlDoctypes() { return array( diff --git a/tests/ZendTest/Form/View/Helper/FormRowTest.php b/tests/ZendTest/Form/View/Helper/FormRowTest.php index 2ca18d0b4b7..c27189d940f 100644 --- a/tests/ZendTest/Form/View/Helper/FormRowTest.php +++ b/tests/ZendTest/Form/View/Helper/FormRowTest.php @@ -373,31 +373,6 @@ public function testAssertButtonElementDoesNotRenderLabelTwice() $this->assertRegexp('#^$#', $markup); } - public function testAssertLabelHtmlEscapeIsOnByDefault() - { - $element = new Element('fooname'); - $escapeHelper = $this->renderer->getHelperPluginManager()->get('escapeHtml'); - - $label = 'foo'; - $element->setLabel($label); - - $markup = $this->helper->__invoke($element); - - $this->assertContains($escapeHelper->__invoke($label), $markup); - } - - public function testCanDisableLabelHtmlEscape() - { - $label = 'foo'; - $element = new Element('fooname'); - $element->setLabel($label); - $element->setLabelOptions(array('disable_html_escape' => true)); - - $markup = $this->helper->__invoke($element); - - $this->assertContains($label, $markup); - } - public function testCanSetLabelPositionBeforeInvoke() { $element = new Element('foo'); diff --git a/tests/ZendTest/Http/Header/AcceptTest.php b/tests/ZendTest/Http/Header/AcceptTest.php index 6506f7fb9eb..18534c9bbcd 100644 --- a/tests/ZendTest/Http/Header/AcceptTest.php +++ b/tests/ZendTest/Http/Header/AcceptTest.php @@ -282,7 +282,7 @@ public function testWildcardWithDifferentParamsAndRanges() /** * @group 3739 - * @covers Zend\Http\Header\AbstractAccept::matchAcceptParams() + * @covers Accept::matchAcceptParams() */ public function testParamRangesWithDecimals() { @@ -293,8 +293,8 @@ public function testParamRangesWithDecimals() /** * @group 3740 * @dataProvider provideParamRanges - * @covers Zend\Http\Header\AbstractAccept::matchAcceptParams() - * @covers Zend\Http\Header\AbstractAccept::getParametersFromFieldValuePart() + * @covers Accept::matchAcceptParams() + * @covers Accept::getParametersFromFieldValuePart() */ public function testParamRangesSupportDevStage($range, $input, $success) { diff --git a/tests/ZendTest/Http/Header/ContentTypeTest.php b/tests/ZendTest/Http/Header/ContentTypeTest.php index f2325d222ed..b6009526395 100644 --- a/tests/ZendTest/Http/Header/ContentTypeTest.php +++ b/tests/ZendTest/Http/Header/ContentTypeTest.php @@ -5,6 +5,7 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_Http */ namespace ZendTest\Http\Header; @@ -29,93 +30,22 @@ public function testContentTypeGetFieldNameReturnsHeaderName() public function testContentTypeGetFieldValueReturnsProperValue() { - $header = ContentType::fromString('Content-Type: application/json'); - $this->assertEquals('application/json', $header->getFieldValue()); - } + $this->markTestIncomplete('ContentType needs to be completed'); - public function testContentTypeToStringReturnsHeaderFormattedString() - { - $header = new ContentType(); - $header->setMediaType('application/atom+xml') - ->setCharset('ISO-8859-1'); - - $this->assertEquals('Content-Type: application/atom+xml; charset=ISO-8859-1', $header->toString()); + $contentTypeHeader = new ContentType(); + $this->assertEquals('xxx', $contentTypeHeader->getFieldValue()); } - /** Implementation specific tests here */ - - public function wildcardMatches() + public function testContentTypeToStringReturnsHeaderFormattedString() { - return array( - 'wildcard' => array('*/*'), - 'wildcard-format' => array('*/*+*'), - 'wildcard-type-subtype-fixed-format' => array('*/*+json'), - 'wildcard-type-partial-wildcard-subtype-fixed-format' => array('*/vnd.*+json'), - 'wildcard-type-format-subtype' => array('*/json'), - 'fixed-type-wildcard-subtype' => array('application/*'), - 'fixed-type-wildcard-subtype-fixed-format' => array('application/*+json'), - 'fixed-type-format-subtype' => array('application/json'), - 'fixed-type-fixed-subtype-wildcard-format' => array('application/vnd.foobar+*'), - 'fixed-type-partial-wildcard-subtype-fixed-format' => array('application/vnd.*+json'), - 'fixed' => array('application/vnd.foobar+json'), - 'fixed-mixed-case' => array('APPLICATION/vnd.FooBar+json'), - ); - } + $this->markTestIncomplete('ContentType needs to be completed'); - /** - * @dataProvider wildcardMatches - */ - public function testMatchWildCard($matchAgainst) - { - $header = ContentType::fromString('Content-Type: application/vnd.foobar+json'); - $result = $header->match($matchAgainst); - $this->assertEquals(strtolower($matchAgainst), $result); - } + $contentTypeHeader = new ContentType(); - public function invalidMatches() - { - return array( - 'format' => array('application/vnd.foobar+xml'), - 'wildcard-subtype' => array('application/vendor.*+json'), - 'subtype' => array('application/vendor.foobar+json'), - 'type' => array('text/vnd.foobar+json'), - 'wildcard-type-format' => array('*/vnd.foobar+xml'), - 'wildcard-type-wildcard-subtype' => array('*/vendor.*+json'), - 'wildcard-type-subtype' => array('*/vendor.foobar+json'), - ); + // @todo set some values, then test output + $this->assertEmpty('Content-Type: xxx', $contentTypeHeader->toString()); } - /** - * @dataProvider invalidMatches - */ - public function testFailedMatches($matchAgainst) - { - $header = ContentType::fromString('Content-Type: application/vnd.foobar+json'); - $result = $header->match($matchAgainst); - $this->assertFalse($result); - } + /** Implmentation specific tests here */ - public function multipleCriteria() - { - $criteria = array( - 'application/vnd.foobar+xml', - 'application/vnd.*+json', - 'application/vendor.foobar+xml', - '*/vnd.foobar+json', - ); - return array( - 'array' => array($criteria), - 'string' => array(implode(',', $criteria)), - ); - } - - /** - * @dataProvider multipleCriteria - */ - public function testReturnsMatchingMediaTypeOfFirstCriteriaToValidate($criteria) - { - $header = ContentType::fromString('Content-Type: application/vnd.foobar+json'); - $result = $header->match($criteria); - $this->assertEquals('application/vnd.*+json', $result); - } } diff --git a/tests/ZendTest/Http/Response/ResponseStreamTest.php b/tests/ZendTest/Http/Response/ResponseStreamTest.php index a8cc8e6be48..eadc87e5caf 100644 --- a/tests/ZendTest/Http/Response/ResponseStreamTest.php +++ b/tests/ZendTest/Http/Response/ResponseStreamTest.php @@ -77,7 +77,7 @@ public function testMultilineHeader() // Check header integrity $this->assertEquals('timeout=15,max=100', $response->getHeaders()->get('keep-alive')->getFieldValue()); - $this->assertEquals('text/html; charset=iso-8859-1', $response->getHeaders()->get('content-type')->getFieldValue()); + $this->assertEquals('text/html;charset=iso-8859-1', $response->getHeaders()->get('content-type')->getFieldValue()); } diff --git a/tests/ZendTest/Http/ResponseTest.php b/tests/ZendTest/Http/ResponseTest.php index 46bac3f657d..338ab79202b 100644 --- a/tests/ZendTest/Http/ResponseTest.php +++ b/tests/ZendTest/Http/ResponseTest.php @@ -316,7 +316,7 @@ public function testMultilineHeader() // Check header integrity $this->assertEquals('timeout=15,max=100', $response->getHeaders()->get('keep-alive')->getFieldValue()); - $this->assertEquals('text/html; charset=iso-8859-1', $response->getHeaders()->get('content-type')->getFieldValue()); + $this->assertEquals('text/html;charset=iso-8859-1', $response->getHeaders()->get('content-type')->getFieldValue()); } /** diff --git a/tests/ZendTest/I18n/Filter/NumberFormatTest.php b/tests/ZendTest/I18n/Filter/NumberFormatTest.php index 8df09fad1cc..cec23e7ba42 100644 --- a/tests/ZendTest/I18n/Filter/NumberFormatTest.php +++ b/tests/ZendTest/I18n/Filter/NumberFormatTest.php @@ -5,6 +5,7 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @package Zend_I18n */ namespace ZendTest\I18n\Filter; diff --git a/tests/ZendTest/I18n/Filter/NumberParseTest.php b/tests/ZendTest/I18n/Filter/NumberParseTest.php deleted file mode 100644 index de643fae87b..00000000000 --- a/tests/ZendTest/I18n/Filter/NumberParseTest.php +++ /dev/null @@ -1,77 +0,0 @@ - 'en_US', - 'style' => NumberFormatter::DECIMAL - )); - - $this->assertEquals('en_US', $filter->getLocale()); - $this->assertEquals(NumberFormatter::DECIMAL, $filter->getStyle()); - } - - public function testConstructWithParameters() - { - $filter = new NumberParseFilter('en_US', NumberFormatter::DECIMAL); - - $this->assertEquals('en_US', $filter->getLocale()); - $this->assertEquals(NumberFormatter::DECIMAL, $filter->getStyle()); - } - - /** - * @param $locale - * @param $style - * @param $type - * @param $value - * @param $expected - * @dataProvider formattedToNumberProvider - */ - public function testFormattedToNumber($locale, $style, $type, $value, $expected) - { - $filter = new NumberParseFilter($locale, $style, $type); - $this->assertSame($expected, $filter->filter($value)); - } - - public static function formattedToNumberProvider() - { - return array( - array( - 'en_US', - NumberFormatter::DEFAULT_STYLE, - NumberFormatter::TYPE_DOUBLE, - '1,234,567.891', - 1234567.891, - ), - array( - 'de_DE', - NumberFormatter::DEFAULT_STYLE, - NumberFormatter::TYPE_DOUBLE, - '1.234.567,891', - 1234567.891, - ), - array( - 'ru_RU', - NumberFormatter::DEFAULT_STYLE, - NumberFormatter::TYPE_DOUBLE, - '1 234 567,891', - 1234567.891, - ), - ); - } -} diff --git a/tests/ZendTest/I18n/Translator/Loader/GettextTest.php b/tests/ZendTest/I18n/Translator/Loader/GettextTest.php index 3fccb30e241..d1c4c57c93c 100644 --- a/tests/ZendTest/I18n/Translator/Loader/GettextTest.php +++ b/tests/ZendTest/I18n/Translator/Loader/GettextTest.php @@ -18,7 +18,6 @@ class GettextTest extends TestCase { protected $testFilesDir; protected $originalLocale; - protected $originalIncludePath; public function setUp() { @@ -26,22 +25,17 @@ public function setUp() Locale::setDefault('en_EN'); $this->testFilesDir = realpath(__DIR__ . '/../_files'); - - $this->originalIncludePath = get_include_path(); - set_include_path($this->testFilesDir . PATH_SEPARATOR . $this->testFilesDir . '/translations.phar'); } public function tearDown() { Locale::setDefault($this->originalLocale); - - set_include_path($this->originalIncludePath); } public function testLoaderFailsToLoadMissingFile() { $loader = new GettextLoader(); - $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not find or open file'); + $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not open file'); $loader->load('en_EN', 'missing'); } @@ -86,24 +80,4 @@ public function testLoaderLoadsPluralRules() $this->assertEquals(1, $textDomain->getPluralRule()->evaluate(2)); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(10)); } - - public function testLoaderLoadsFromIncludePath() - { - $loader = new GettextLoader(); - $loader->setUseIncludePath(true); - $textDomain = $loader->load('en_EN', 'translation_en.mo'); - - $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); - $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); - } - - public function testLoaderLoadsFromPhar() - { - $loader = new GettextLoader(); - $loader->setUseIncludePath(true); - $textDomain = $loader->load('en_EN', 'phar://' . $this->testFilesDir . '/translations.phar/translation_en.mo'); - - $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); - $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); - } } diff --git a/tests/ZendTest/I18n/Translator/Loader/IniTest.php b/tests/ZendTest/I18n/Translator/Loader/IniTest.php index 47377592fe2..3d7eee63f32 100644 --- a/tests/ZendTest/I18n/Translator/Loader/IniTest.php +++ b/tests/ZendTest/I18n/Translator/Loader/IniTest.php @@ -18,25 +18,16 @@ class IniTest extends TestCase { protected $testFilesDir; protected $originalLocale; - protected $originalIncludePath; public function setUp() { $this->testFilesDir = realpath(__DIR__ . '/../_files'); - - $this->originalIncludePath = get_include_path(); - set_include_path($this->testFilesDir . PATH_SEPARATOR . $this->testFilesDir . '/translations.phar'); - } - - public function tearDown() - { - set_include_path($this->originalIncludePath); } public function testLoaderFailsToLoadMissingFile() { $loader = new IniLoader(); - $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not find or open file'); + $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not open file'); $loader->load('en_EN', 'missing'); } @@ -100,24 +91,4 @@ public function testLoaderLoadsPluralRules() $this->assertEquals(1, $textDomain->getPluralRule()->evaluate(2)); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(10)); } - - public function testLoaderLoadsFromIncludePath() - { - $loader = new IniLoader(); - $loader->setUseIncludePath(true); - $textDomain = $loader->load('en_EN', 'translation_en.ini'); - - $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); - $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); - } - - public function testLoaderLoadsFromPhar() - { - $loader = new IniLoader(); - $loader->setUseIncludePath(true); - $textDomain = $loader->load('en_EN', 'phar://' . $this->testFilesDir . '/translations.phar/translation_en.ini'); - - $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); - $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); - } } diff --git a/tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php b/tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php index 0543b29a5f4..c774ff32945 100644 --- a/tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php +++ b/tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php @@ -18,7 +18,6 @@ class PhpArrayTest extends TestCase { protected $testFilesDir; protected $originalLocale; - protected $originalIncludePath; public function setUp() { @@ -26,22 +25,17 @@ public function setUp() Locale::setDefault('en_EN'); $this->testFilesDir = realpath(__DIR__ . '/../_files'); - - $this->originalIncludePath = get_include_path(); - set_include_path($this->testFilesDir . PATH_SEPARATOR . $this->testFilesDir . '/translations.phar'); } public function tearDown() { Locale::setDefault($this->originalLocale); - - set_include_path($this->originalIncludePath); } public function testLoaderFailsToLoadMissingFile() { $loader = new PhpArrayLoader(); - $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not find or open file'); + $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not open file'); $loader->load('en_EN', 'missing'); } @@ -79,24 +73,4 @@ public function testLoaderLoadsPluralRules() $this->assertEquals(1, $textDomain->getPluralRule()->evaluate(2)); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(10)); } - - public function testLoaderLoadsFromIncludePath() - { - $loader = new PhpArrayLoader(); - $loader->setUseIncludePath(true); - $textDomain = $loader->load('en_EN', 'translation_en.php'); - - $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); - $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); - } - - public function testLoaderLoadsFromPhar() - { - $loader = new PhpArrayLoader(); - $loader->setUseIncludePath(true); - $textDomain = $loader->load('en_EN', 'phar://' . $this->testFilesDir . '/translations.phar/translation_en.php'); - - $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); - $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); - } } diff --git a/tests/ZendTest/I18n/Translator/_files/translations.phar b/tests/ZendTest/I18n/Translator/_files/translations.phar deleted file mode 100644 index 420d924d49a05031be8829243c9faa68dd9ff8f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9664 zcmcgyO>87r5q2Pf&=4eolmiOVTWhjCUc2Yd_IerrtarV$yH@O7$DTN0oz5-rkL}$gXC&?%B5?q5<(vcJfRqa$BrZrCkU(7FfDnnq3GvnYX?M@hCI?`wR`;t{ zRj;aEy{dZedE;g@hzz52&bw@rnQ3eXiEpP~7<5veq*X6)`9%dd=DJ~cJy!ODjvdGL zld>5N?ATmlNg8u|*y;1Ma~|7K#N(vAu)wZfWsYwrNrzu}Nt%?+1BqTk-+Kl%noTcA zdF=2gz3ch>?kI3Txo#xjY#p^bZyxTNkA*R2VeGfs_aEL-NK-iIezu9} zxz}o&?EUxIZC)0opqQqpITdc8Un2z`| zQ+|m9NiM8{N=-B1s1IEgHaLf@&Vl6QxURK1W{#ilA0RU_&F%=S)V$37N|adLgN) zW>zKD?um&^#e)Q83oH-D^ES$Mv;Z0|8JC-9x!aWiCTaRFd@^aC)|% z@CArl>P6HHBSaJ(9haCHcWHg}63$P{Ktc7({a&+)0RS%Tfn*d!wsTrGk5L+nm0s?8 zfgL|t=#dXeq7^DkOG9AmPLs-OH-sZV7TZP7jrw;Wt#E<8llo(#+zd%2y2#gNwmHE5w`912tTam(AAU z;lslwLjd)9*i0~lXDl#^eJ(q<6E+W5#C*uG4bByFo+0gye3x~(?3H>Ukj|6g;anvO z0Z>UAzN5@t8j>nKz(xNFD%i(LK0vQ3?0b*IQlku~r$5`C^q+z;c0L@1b0&WrhjEiV z^}R030u1vKq~DYwiFSQt2#b_3Sw>%8V467#ICp{43uD2=a>8L0b3_c6VNYepiBw8$ zBXW|$>t~DFed=<}X;RwmQ!i?Krnq??GbHXlZ9GF@v5>QQNQV*C0NN+6$X;ZqD_(+a zp_h`a%CaaBZkxagSbY@J1ryQgBq+D!o)4VJ_u(8UL=Zo7_(&e>^9$?>LZ@1;`Cj5C zs)})<*{l}pYP2g9LbXTanJ!SWB~?htLPzE+JHlX( zCWiKtjHX}CzP4nZuXJ@{!LT~bDq$Ev%xoq^vUvm!Z2V(~}ORa&xNIaLln4;O${_ zmy)jZlBG<-XN$NkrYstz9fW$y^ol;Ky(Wi77$-X!Sd|<#H2j1@%85BNA2S4{lJva%quWI53hk_1~oB0x5{ ztYh=jmnkji_rrpkg6=t&pirDA|tC9S~*aY3#h4aw2Ly=0BA z`-q9+DI%9B+vk{L*K zjU{TA9CdvK`>&FZIt8MX=vZk6hl~NGaMXAu_y*~0Xd%6$ z_>l`1xcFLJB#UEk9spy;uyPosq8f7%gRX;+a*j?zYC8&hXbR%1)e@qDOu<0Rm=qSF z<0NB*)hSQaI@pwt5YRHA?CNp1dhAq>-Rd!~9^>#J+X3f>Y+xeDjKT~>&L_*nJc(kQ zoc7A*Ya=Q$r{ft{QAqdHZx*{XVpj?=Sjb4RX{;JFC32d8(hw6h4R5tDb??vMw(>Zu z#;A(Vtq2-?svl1aL+FY8f883I)oHolBg@r!+WCEIvNb``+D z5*@-V(i1olU<-7*R8$=xJ{fIaS?p04l($P6W

ed4)!kZI1%q3ux;IW6?B^QPZu7t}-RB86{G$P#>u@tB0c01pbpXg;Gr`t6a5J zxZ%Kd7_^o}^y=44yZf@>*Jm0|c93J_58L#}s5f3U};2nN( zZtlv5KYN4T(Lew2_m3386l|Qv|3G2W+xgeef2Fa%0^Zq%{yG}OlHQ-Z^4mXaBob## zfMNJ!#gX2>sScjg$S09Mif#X~A>SQL@Q^Z=8Aw2~xxCKg=Vm#0tzO&Qtkb;EXYI;n zy^cw(VJ@k?wb{^J8=EWiDJW_i^%_+Mf&@4DVVvY-eQe;OA;5{T$K!eh zS27817#PHv-&f!D`2tFgwur{cJXn}V0Lb_?rt)j#`86uD_%$Z^El=gQoaeVZli%_r zzm=){R`UE-X7XE^*pOiFIz zt``*93Byw_=;Kr&4m`v+o|o);ULi5S>mUCD!7*U_AAi*4{-l-G3e1bxdCqGSoF@cP z%s0dxa`oCZgI!~fc;K?TF^;3p!}yey2WcANZndW&m8U?c;P|4t0Cb|*rjUqI3O|M1 z_tL?rE072~qpd#eHN;^`I^fK)gD}8NmCurJgj-}BE8(cXqkXpE>V(k~oGuPhwv&C8 zQ3T*1an)+n>dR8pHV(Uk5O<9pu0!8Ey2W+_r;>?%etw<_O!AVj4i1{JM76M)bQxk* z;Zy^DZgmrvJ>ci;_R$@-Cus#AIwcfKU5L@yt=|X$uNr!TpzdYKDyFy@$^is0AHL+( z(f=!e(eMjPRQ)nDi&9dAtSMXrcUT3aMiEJdm~kX^1E@L4xG|2jQsg9q!8p>YKpL}K zP293+?qh3SaUh}V&%mqa@NhbfyVU9Y8m7=++iGI{NF|C(uwb}imqef7qA8HJ}>jc ziv2a7ujBb69?HvqRqs#K``_yQA~OBA@clC0ALFs`d=u?|d|__x6}(?SMkYS5s`sLL zH`RL=?|bNf8*h-#flO2#FW?Q(+?Vjs@5}Nf8+TgLwGe(O^HdZlLQ zOR({avUTRrK{Zb|M`_QxafwG`_jqiz0w;8lpPKAO*GmnVKCQb{RiQ|dQR;tOQ^6WR ze}rgiwehb=F!$TmLC9S%wT?t;*pV7EnN(rSE5!PloA4b8&OD~rl%Xs04jH7frVK|} vb1cZrfM5D#5x+6lI{f{oM=$OFassertEquals(2, count($validators)); $this->assertEquals($notEmptyMock, $validators[1]['instance']); } - - public function dataFallbackValue() - { - return array( - array( - 'fallbackValue' => array() - ), - array( - 'fallbackValue' => array(''), - ), - array( - 'fallbackValue' => array(null), - ), - array( - 'fallbackValue' => array('some value'), - ), - ); - } - - /** - * @dataProvider dataFallbackValue - */ - public function testFallbackValue($fallbackValue) - { - $this->input->setFallbackValue($fallbackValue); - $validator = new Validator\Date(); - $this->input->getValidatorChain()->attach($validator); - $this->input->setValue(array('123')); // not a date - - $this->assertTrue($this->input->isValid()); - $this->assertEmpty($this->input->getMessages()); - $this->assertSame($fallbackValue, $this->input->getValue()); - } } diff --git a/tests/ZendTest/InputFilter/FileInputTest.php b/tests/ZendTest/InputFilter/FileInputTest.php index a72a79877d7..22d18c4066f 100644 --- a/tests/ZendTest/InputFilter/FileInputTest.php +++ b/tests/ZendTest/InputFilter/FileInputTest.php @@ -340,9 +340,4 @@ public function testMerge() $filters = $filterChain->getFilters()->toArray(); $this->assertInstanceOf('Zend\Filter\StringTrim', $filters[0]); } - - public function testFallbackValue($fallbackValue = null) - { - $this->markTestSkipped('Not use fallback value'); - } } diff --git a/tests/ZendTest/InputFilter/InputTest.php b/tests/ZendTest/InputFilter/InputTest.php index 24338dd679c..f3638ffcae8 100644 --- a/tests/ZendTest/InputFilter/InputTest.php +++ b/tests/ZendTest/InputFilter/InputTest.php @@ -273,36 +273,6 @@ public function testDoNotInjectNotEmptyValidatorIfAnywhereInChain() $this->assertEquals($notEmptyMock, $validators[1]['instance']); } - public function dataFallbackValue() - { - return array( - array( - 'fallbackValue' => null - ), - array( - 'fallbackValue' => '' - ), - array( - 'fallbackValue' => 'some value' - ), - ); - } - - /** - * @dataProvider dataFallbackValue - */ - public function testFallbackValue($fallbackValue) - { - $this->input->setFallbackValue($fallbackValue); - $validator = new Validator\Date(); - $this->input->getValidatorChain()->attach($validator); - $this->input->setValue('123'); // not a date - - $this->assertTrue($this->input->isValid()); - $this->assertEmpty($this->input->getMessages()); - $this->assertSame($fallbackValue, $this->input->getValue()); - } - public function testMergeRetainsContinueIfEmptyFlag() { $input = new Input('foo'); diff --git a/tests/ZendTest/Json/JsonTest.php b/tests/ZendTest/Json/JsonTest.php index ff8c1e0a099..ed0aecbb0cb 100644 --- a/tests/ZendTest/Json/JsonTest.php +++ b/tests/ZendTest/Json/JsonTest.php @@ -463,29 +463,7 @@ public function testToJSONSerialization() $this->assertEquals('{"firstName":"John","lastName":"Doe","email":"john@doe.com"}', $result); } - public function testJsonSerializableWithBuiltinImplementation() - { - if (version_compare(PHP_VERSION, '5.4.0', 'lt')) { - $this->markTestSkipped('JsonSerializable does not exist in PHP <5.4.0.'); - } - - $encoded = Json\Encoder::encode( - new TestAsset\JsonSerializableBuiltinImpl() - ); - - $this->assertEquals('["jsonSerialize"]', $encoded); - } - - public function testJsonSerializableWithZFImplementation() - { - $encoded = Json\Encoder::encode( - new TestAsset\JsonSerializableZFImpl() - ); - - $this->assertEquals('["jsonSerialize"]', $encoded); - } - - /** + /** * test encoding array with Zend_JSON_Expr * * @group ZF-4946 diff --git a/tests/ZendTest/Json/TestAsset/JsonSerializableBuiltinImpl.php b/tests/ZendTest/Json/TestAsset/JsonSerializableBuiltinImpl.php deleted file mode 100644 index c31ff9121d2..00000000000 --- a/tests/ZendTest/Json/TestAsset/JsonSerializableBuiltinImpl.php +++ /dev/null @@ -1,26 +0,0 @@ -setExpectedException('Zend\Log\Exception\InvalidArgumentException', 'must be numeric'); - new Sample('bar'); - } - - public function testSampleLimit0() - { - // Should log nothing. - $filter = new Sample(0); - - // Since sampling is a random process, let's test several times. - $ret = false; - for ($i = 0; $i < 100; $i ++) { - if ($filter->filter(array())) { - break; - $ret = true; - } - } - - $this->assertFalse($ret); - } - - public function testSampleLimit1() - { - // Should log all events. - $filter = new Sample(1); - - // Since sampling is a random process, let's test several times. - $ret = true; - for ($i = 0; $i < 100; $i ++) { - if (! $filter->filter(array())) { - break; - $ret = false; - } - } - - $this->assertTrue($ret); - } -} diff --git a/tests/ZendTest/ModuleManager/Listener/ConfigListenerTest.php b/tests/ZendTest/ModuleManager/Listener/ConfigListenerTest.php index d92a3544423..f171d1609b5 100644 --- a/tests/ZendTest/ModuleManager/Listener/ConfigListenerTest.php +++ b/tests/ZendTest/ModuleManager/Listener/ConfigListenerTest.php @@ -378,7 +378,7 @@ public function testConfigListenerFunctionsAsAggregateListener() $this->assertEquals(2, count($moduleManager->getEventManager()->getEvents())); $configListener->attach($moduleManager->getEventManager()); - $this->assertEquals(4, count($moduleManager->getEventManager()->getEvents())); + $this->assertEquals(3, count($moduleManager->getEventManager()->getEvents())); $configListener->detach($moduleManager->getEventManager()); $this->assertEquals(2, count($moduleManager->getEventManager()->getEvents())); diff --git a/tests/ZendTest/ModuleManager/Listener/DefaultListenerAggregateTest.php b/tests/ZendTest/ModuleManager/Listener/DefaultListenerAggregateTest.php index 39f4dcf38e6..79ec16bdda1 100644 --- a/tests/ZendTest/ModuleManager/Listener/DefaultListenerAggregateTest.php +++ b/tests/ZendTest/ModuleManager/Listener/DefaultListenerAggregateTest.php @@ -109,7 +109,7 @@ public function testDefaultListenerAggregateCanDetachItself() $this->assertEquals(1, count($moduleManager->getEventManager()->getEvents())); $listenerAggregate->attach($moduleManager->getEventManager()); - $this->assertEquals(4, count($moduleManager->getEventManager()->getEvents())); + $this->assertEquals(3, count($moduleManager->getEventManager()->getEvents())); $listenerAggregate->detach($moduleManager->getEventManager()); $this->assertEquals(1, count($moduleManager->getEventManager()->getEvents())); diff --git a/tests/ZendTest/Mvc/ApplicationTest.php b/tests/ZendTest/Mvc/ApplicationTest.php index 405544cc22e..8ab27b8f2f9 100644 --- a/tests/ZendTest/Mvc/ApplicationTest.php +++ b/tests/ZendTest/Mvc/ApplicationTest.php @@ -332,15 +332,14 @@ public function testAllowsReturningEarlyFromRouting() }); $result = $this->application->run(); - $this->assertSame($this->application, $result); - $this->assertSame($response, $result->getResponse()); + $this->assertSame($response, $result); } public function testControllerIsDispatchedDuringRun() { $this->setupPathController(); - $response = $this->application->run()->getResponse(); + $response = $this->application->run(); $this->assertContains('PathController', $response->getContent()); $this->assertContains('dispatch', $response->toString()); } @@ -497,8 +496,7 @@ public function testLocatorExceptionShouldTriggerDispatchError() }); $result = $this->application->run(); - $this->assertSame($this->application, $result, get_class($result)); - $this->assertSame($response, $result->getResponse(), get_class($result)); + $this->assertSame($response, $result, var_export($result, 1)); } /** diff --git a/tests/ZendTest/Mvc/Controller/ControllerManagerTest.php b/tests/ZendTest/Mvc/Controller/ControllerManagerTest.php index 83d98e25ae0..f06857bd8db 100644 --- a/tests/ZendTest/Mvc/Controller/ControllerManagerTest.php +++ b/tests/ZendTest/Mvc/Controller/ControllerManagerTest.php @@ -62,8 +62,8 @@ public function testInjectControllerDependenciesWillNotOverwriteExistingEventMan } /** - * @covers Zend\ServiceManager\ServiceManager::has - * @covers Zend\ServiceManager\AbstractPluginManager::get + * @covers ControllerManager::has + * @covers ControllerManager::get */ public function testDoNotUsePeeringServiceManagers() { diff --git a/tests/ZendTest/Mvc/Controller/Plugin/RedirectTest.php b/tests/ZendTest/Mvc/Controller/Plugin/RedirectTest.php index 71c6b72621b..e109e497434 100644 --- a/tests/ZendTest/Mvc/Controller/Plugin/RedirectTest.php +++ b/tests/ZendTest/Mvc/Controller/Plugin/RedirectTest.php @@ -111,12 +111,6 @@ public function testPluginWithoutRouteMatchesInEventRaisesExceptionWhenNoRoutePr $url = $this->plugin->toRoute(); } - /** - * This block is required to bypass a PCRE bug in 5.3.3 - * - * @todo Remove once we no longer support 5.3.3 - * @return void - */ public function testPluginWithRouteMatchesReturningNoMatchedRouteNameRaisesExceptionWhenNoRouteProvided() { $event = $this->controller->getEvent(); diff --git a/tests/ZendTest/Mvc/Router/Console/SimpleTest.php b/tests/ZendTest/Mvc/Router/Console/SimpleTest.php index 9cdee7d6dc0..eb204c89d3c 100644 --- a/tests/ZendTest/Mvc/Router/Console/SimpleTest.php +++ b/tests/ZendTest/Mvc/Router/Console/SimpleTest.php @@ -16,6 +16,872 @@ class SimpleTest extends TestCase { + public static function routeProvider() + { + return array( + // -- mandatory long flags + 'mandatory-long-flag-no-match' => array( + '--foo --bar', + array('a','b','--baz'), + null + ), + 'mandatory-long-flag-no-partial-match' => array( + '--foo --bar', + array('--foo','--baz'), + null + ), + 'mandatory-long-flag-match' => array( + '--foo --bar', + array('--foo','--bar'), + array('foo' => true, 'bar' => true) + ), + 'mandatory-long-flag-match-with-zero-value' => array( + '--foo=', + array('--foo=0'), + array('foo' => 0) + ), + 'mandatory-long-flag-mixed-order-match' => array( + '--foo --bar', + array('--bar','--foo'), + array('foo' => true, 'bar' => true) + ), + 'mandatory-long-flag-whitespace-in-definition' => array( + ' --foo --bar ', + array('--bar','--foo'), + array( + 'foo' => true, + 'bar' => true, + 'baz' => null, + ) + ), + 'mandatory-long-flag-alternative1' => array( + ' ( --foo | --bar )', + array('--foo'), + array( + 'foo' => true, + 'bar' => false, + 'baz' => null, + ) + ), + 'mandatory-long-flag-alternative2' => array( + ' ( --foo | --bar )', + array('--bar'), + array( + 'foo' => false, + 'bar' => true, + 'baz' => null, + ) + ), + 'mandatory-long-flag-alternative3' => array( + ' ( --foo | --bar )', + array('--baz'), + null + ), + + // -- mandatory short flags + 'mandatory-short-flag-no-match' => array( + '-f -b', + array('a','b','-f'), + null + ), + 'mandatory-short-flag-no-partial-match' => array( + '-f -b', + array('-f','-z'), + null + ), + 'mandatory-short-flag-match' => array( + '-f -b', + array('-f','-b'), + array('f' => true, 'b' => true) + ), + 'mandatory-short-flag-mixed-order-match' => array( + '-f -b', + array('-b','-f'), + array('f' => true, 'b' => true) + ), + 'mandatory-short-flag-whitespace-in-definition' => array( + ' -f -b ', + array('-b','-f'), + array( + 'f' => true, + 'b' => true, + 'baz' => null, + ) + ), + 'mandatory-short-flag-alternative1' => array( + ' ( -f | -b )', + array('-f'), + array( + 'f' => true, + 'b' => false, + 'baz' => null, + ) + ), + 'mandatory-short-flag-alternative2' => array( + ' ( -f | -b )', + array('-b'), + array( + 'f' => false, + 'b' => true, + 'baz' => null, + ) + ), + 'mandatory-short-flag-alternative3' => array( + ' ( -f | -b )', + array('--baz'), + null + ), + + // -- optional long flags + 'optional-long-flag-non-existent' => array( + '--foo [--bar]', + array('--foo'), + array( + 'foo' => true, + 'bar' => null, + 'baz' => null, + ) + ), + 'literal-optional-long-flag' => array( + 'foo [--bar]', + array('foo', '--bar'), + array( + 'foo' => null, + 'bar' => true, + ) + ), + 'optional-long-flag-partial-mismatch' => array( + '--foo [--bar]', + array('--foo', '--baz'), + null + ), + 'optional-long-flag-match' => array( + '--foo [--bar]', + array('--foo','--bar'), + array( + 'foo' => true, + 'bar' => true + ) + ), + 'optional-long-value-flag-non-existent' => array( + '--foo [--bar=]', + array('--foo'), + array( + 'foo' => true, + 'bar' => false + ) + ), + 'optional-long-flag-match-with-zero-value' => array( + '[--foo=]', + array('--foo=0'), + array('foo' => 0) + ), + 'optional-long-value-flag' => array( + '--foo [--bar=]', + array('--foo', '--bar=4'), + array( + 'foo' => true, + 'bar' => 4 + ) + ), + 'optional-long-value-flag-non-existent-mixed-case' => array( + '--foo [--barBaz=]', + array('--foo', '--barBaz=4'), + array( + 'foo' => true, + 'barBaz' => 4 + ) + ), + 'value-optional-long-value-flag' => array( + ' [--bar=]', + array('value', '--bar=4'), + array( + 'foo' => 'value', + 'bar' => 4 + ) + ), + 'literal-optional-long-value-flag' => array( + 'foo [--bar=]', + array('foo', '--bar=4'), + array( + 'foo' => null, + 'bar' => 4, + ) + ), + 'optional-long-flag-mixed-order-match' => array( + '--foo --bar', + array('--bar','--foo'), + array('foo' => true, 'bar' => true) + ), + 'optional-long-flag-whitespace-in-definition' => array( + ' --foo [--bar] ', + array('--bar','--foo'), + array( + 'foo' => true, + 'bar' => true, + 'baz' => null, + ) + ), + 'optional-long-flag-whitespace-in-definition2' => array( + ' --foo [--bar ] ', + array('--bar','--foo'), + array( + 'foo' => true, + 'bar' => true, + 'baz' => null, + ) + ), + 'optional-long-flag-whitespace-in-definition3' => array( + ' --foo [ --bar ] ', + array('--bar','--foo'), + array( + 'foo' => true, + 'bar' => true, + 'baz' => null, + ) + ), + + + // -- value flags + 'mandatory-value-flag-syntax-1' => array( + '--foo=s', + array('--foo','bar'), + array( + 'foo' => 'bar', + 'bar' => null + ) + ), + 'mandatory-value-flag-syntax-2' => array( + '--foo=', + array('--foo','bar'), + array( + 'foo' => 'bar', + 'bar' => null + ) + ), + 'mandatory-value-flag-syntax-3' => array( + '--foo=anystring', + array('--foo','bar'), + array( + 'foo' => 'bar', + 'bar' => null + ) + ), + + // -- edge cases for value flags values + 'mandatory-value-flag-equals-complex-1' => array( + '--foo=', + array('--foo=SomeComplexValue=='), + array('foo' => 'SomeComplexValue==') + ), + 'mandatory-value-flag-equals-complex-2' => array( + '--foo=', + array('--foo=..., '..., array( + '--foo=', + array('--foo====--'), + array('foo' => '===--') + ), + 'mandatory-value-flag-space-complex-1' => array( + '--foo=', + array('--foo','SomeComplexValue=='), + array('foo' => 'SomeComplexValue==') + ), + 'mandatory-value-flag-space-complex-2' => array( + '--foo=', + array('--foo','..., '..., array( + '--foo=', + array('--foo','===--'), + array('foo' => '===--') + ), + + // -- required literal params + 'mandatory-literal-match-1' => array( + 'foo', + array('foo'), + array('foo' => null) + ), + 'mandatory-literal-match-2' => array( + 'foo bar baz', + array('foo','bar','baz'), + array('foo' => null, 'bar' => null, 'baz' => null, 'bazinga' => null) + ), + 'mandatory-literal-mismatch' => array( + 'foo', + array('fooo'), + null + ), + 'mandatory-literal-order' => array( + 'foo bar', + array('bar','foo'), + null + ), + 'mandatory-literal-partial-mismatch' => array( + 'foo bar baz', + array('foo','bar'), + null + ), + 'mandatory-literal-alternative-match-1' => array( + 'foo ( bar | baz )', + array('foo','bar'), + array('foo' => null, 'bar' => true, 'baz' => false) + ), + 'mandatory-literal-alternative-match-2' => array( + 'foo (bar|baz)', + array('foo','bar'), + array('foo' => null, 'bar' => true, 'baz' => false) + ), + 'mandatory-literal-alternative-match-3' => array( + 'foo ( bar | baz )', + array('foo','baz'), + array('foo' => null, 'bar' => false, 'baz' => true) + ), + 'mandatory-literal-alternative-mismatch' => array( + 'foo ( bar | baz )', + array('foo','bazinga'), + null + ), + 'mandatory-literal-namedAlternative-match-1' => array( + 'foo ( bar | baz ):altGroup', + array('foo','bar'), + array('foo' => null, 'altGroup'=>'bar', 'bar' => true, 'baz' => false) + ), + 'mandatory-literal-namedAlternative-match-2' => array( + 'foo ( bar | baz ):altGroup9', + array('foo','baz'), + array('foo' => null, 'altGroup9'=>'baz', 'bar' => false, 'baz' => true) + ), + 'mandatory-literal-namedAlternative-mismatch' => array( + 'foo ( bar | baz ):altGroup9', + array('foo','bazinga'), + null + ), + + // -- optional literal params + 'optional-literal-match' => array( + 'foo [bar] [baz]', + array('foo','bar'), + array('foo' => null, 'bar' => true, 'baz' => null) + ), + 'optional-literal-mismatch' => array( + 'foo [bar] [baz]', + array('baz','bar'), + null + ), + 'optional-literal-shuffled-mismatch' => array( + 'foo [bar] [baz]', + array('foo','baz','bar'), + null + ), + 'optional-literal-alternative-match' => array( + 'foo [bar | baz]', + array('foo','baz'), + array('foo' => null, 'baz' => true, 'bar' => false) + ), + 'optional-literal-alternative-mismatch' => array( + 'foo [bar | baz]', + array('foo'), + array('foo' => null, 'baz' => false, 'bar' => false) + ), + 'optional-literal-namedAlternative-match-1' => array( + 'foo [bar | baz]:altGroup1', + array('foo','baz'), + array('foo' => null, 'altGroup1' => 'baz', 'baz' => true, 'bar' => false) + ), + 'optional-literal-namedAlternative-match-2' => array( + 'foo [bar | baz | bazinga]:altGroup100', + array('foo','bazinga'), + array('foo' => null, 'altGroup100' => 'bazinga', 'bazinga' => true, 'baz' => false, 'bar' => false) + ), + 'optional-literal-namedAlternative-match-3' => array( + 'foo [ bar ]:altGroup100', + array('foo','bar'), + array('foo' => null, 'altGroup100' => 'bar', 'bar' => true, 'baz' => null) + ), + 'optional-literal-namedAlternative-mismatch' => array( + 'foo [ bar | baz ]:altGroup9', + array('foo'), + array('foo' => null, 'altGroup9'=> null, 'bar' => false, 'baz' => false) + ), + + // -- value params + 'mandatory-value-param-syntax-1' => array( + 'FOO', + array('bar'), + array( + 'foo' => 'bar', + 'bar' => null + ) + ), + 'mandatory-value-param-syntax-2' => array( + '', + array('bar'), + array( + 'foo' => 'bar', + 'bar' => null + ) + ), + 'mandatory-value-param-mixed-with-literal' => array( + 'a b c', + array('a','b','bar','c'), + array( + 'a' => null, + 'b' => null, + 'foo' => 'bar', + 'bar' => null, + 'c' => null, + ), + ), + 'optional-value-param-1' => array( + 'a b []', + array('a','b','bar'), + array( + 'a' => null, + 'b' => null, + 'c' => 'bar', + 'bar' => null, + ), + ), + 'optional-value-param-2' => array( + 'a b []', + array('a','b'), + array( + 'a' => null, + 'b' => null, + 'c' => null, + 'bar' => null, + ), + ), + 'optional-value-param-3' => array( + 'a b []', + array('a','b','--c'), + null + ), + + // -- combinations + 'mandatory-long-short-alternative-1' => array( + ' ( --foo | -f )', + array('--foo'), + array( + 'foo' => true, + 'f' => false, + 'baz' => null, + ) + ), + 'mandatory-long-short-alternative-2' => array( + ' ( --foo | -f )', + array('-f'), + array( + 'foo' => false, + 'f' => true, + 'baz' => null, + ) + ), + 'optional-long-short-alternative-1' => array( + 'a [ --foo | -f ]', + array('a','bar'), + array( + 'a' => null, + 'b' => 'bar', + 'foo' => false, + 'f' => false, + 'baz' => null, + ) + ), + 'optional-long-short-alternative-2' => array( + 'a [ --foo | -f ]', + array('a','bar', '-f'), + array( + 'a' => null, + 'b' => 'bar', + 'foo' => false, + 'f' => true, + 'baz' => null, + ) + ), + 'optional-long-short-alternative-3' => array( + 'a [ --foo | -f ]', + array('a','--foo', 'bar'), + array( + 'a' => null, + 'b' => 'bar', + 'foo' => true, + 'f' => false, + 'baz' => null, + ) + ), + + + 'mandatory-and-optional-value-params-with-flags-1' => array( + 'a b [] [--eee|-e] [--fff|-f]', + array('a','b','foo','bar'), + array( + 'a' => null, + 'b' => null, + 'c' => 'foo', + 'd' => 'bar', + 'e' => false, + 'eee' => false, + 'fff' => false, + 'f' => false, + ), + ), + 'mandatory-and-optional-value-params-with-flags-2' => array( + 'a b [] [--eee|-e] [--fff|-f]', + array('a','b','--eee', 'foo','bar'), + array( + 'a' => null, + 'b' => null, + 'c' => 'foo', + 'd' => 'bar', + 'e' => false, + 'eee' => true, + 'fff' => false, + 'f' => false, + ), + ), + + + // -- overflows + 'too-many-arguments1' => array( + 'foo bar', + array('foo','bar','baz'), + null + ), + 'too-many-arguments2' => array( + 'foo bar [baz]', + array('foo','bar','baz','woo'), + null, + ), + 'too-many-arguments3' => array( + 'foo bar [--baz]', + array('foo','bar','--baz','woo'), + null, + ), + 'too-many-arguments4' => array( + 'foo bar [--baz] woo', + array('foo','bar','woo'), + array( + 'foo' => null, + 'bar' => null, + 'baz' => false, + 'woo' => null + ) + ), + 'too-many-arguments5' => array( + '--foo --bar [--baz] woo', + array('--bar','--foo','woo'), + array( + 'foo' => true, + 'bar' => true, + 'baz' => false, + 'woo' => null + ) + ), + 'too-many-arguments6' => array( + '--foo --bar [--baz]', + array('--bar','--foo','woo'), + null + ), + + // other (combination) + 'combined-1' => array( + 'literal [--foo=] --baz', + array('literal', 'oneBar', '--foo=4', '--baz'), + array( + 'literal' => null, + 'bar' => 'oneBar', + 'foo' => 4, + 'baz' => true + ) + ), + // group with group name diferent than options (short) + 'group-1' => array( + 'group [-t|--test]:testgroup', + array('group', '-t'), + array( + 'group' => null, + 'testgroup' => true, + ) + ), + // group with group name diferent than options (long) + 'group-2' => array( + 'group [-t|--test]:testgroup', + array('group', '--test'), + array( + 'group' => null, + 'testgroup' => true, + ) + ), + // group with same name as option (short) + 'group-3' => array( + 'group [-t|--test]:test', + array('group', '-t'), + array( + 'group' => null, + 'test' => true, + ) + ), + // group with same name as option (long) + 'group-4' => array( + 'group [-t|--test]:test', + array('group', '--test'), + array( + 'group' => null, + 'test' => true, + ) + ), + 'group-5' => array( + 'group (-t | --test ):test', + array('group', '--test'), + array( + 'group' => null, + 'test' => true, + ), + ), + 'group-6' => array( + 'group (-t | --test ):test', + array('group', '-t'), + array( + 'group' => null, + 'test' => true, + ), + ), + 'group-7' => array( + 'group [-x|-y|-z]:test', + array('group', '-y'), + array( + 'group' => null, + 'test' => true, + ), + ), + 'group-8' => array( + 'group [--foo|--bar|--baz]:test', + array('group', '--foo'), + array( + 'group' => null, + 'test' => true, + ), + ), + 'group-9' => array( + 'group (--foo|--bar|--baz):test', + array('group', '--foo'), + array( + 'group' => null, + 'test' => true, + ), + ), + + /** + * @bug ZF2-4315 + * @link https://github.com/zendframework/zf2/issues/4315 + */ + 'literal-with-dashes' => array( + 'foo-bar-baz [--bar=]', + array('foo-bar-baz',), + array( + 'foo-bar-baz' => null, + 'foo' => null, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + + 'literal-optional-with-dashes' => array( + '[foo-bar-baz] [--bar=]', + array('foo-bar-baz'), + array( + 'foo-bar-baz' => true, + 'foo' => null, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-with-dashes2' => array( + 'foo [foo-bar-baz] [--bar=]', + array('foo'), + array( + 'foo-bar-baz' => false, + 'foo' => null, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-alternative-with-dashes' => array( + '(foo-bar|foo-baz) [--bar=]', + array('foo-bar',), + array( + 'foo-bar' => true, + 'foo-baz' => false, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-alternative-with-dashes' => array( + '[foo-bar|foo-baz] [--bar=]', + array('foo-baz',), + array( + 'foo-bar' => false, + 'foo-baz' => true, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-alternative-with-dashes2' => array( + 'foo [foo-bar|foo-baz] [--bar=]', + array('foo',), + array( + 'foo' => null, + 'foo-bar' => false, + 'foo-baz' => false, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-flag-with-dashes' => array( + 'foo --bar-baz', + array('foo','--bar-baz'), + array( + 'foo' => null, + 'bar-baz' => true, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-flag-with-dashes' => array( + 'foo [--bar-baz]', + array('foo','--bar-baz'), + array( + 'foo' => null, + 'bar-baz' => true, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-flag-with-dashes2' => array( + 'foo [--bar-baz]', + array('foo'), + array( + 'foo' => null, + 'bar-baz' => false, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-flag-alternative-with-dashes' => array( + 'foo [--foo-bar|--foo-baz]', + array('foo','--foo-baz'), + array( + 'foo' => null, + 'foo-bar' => false, + 'foo-baz' => true, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'literal-optional-flag-alternative-with-dashes2' => array( + 'foo [--foo-bar|--foo-baz]', + array('foo'), + array( + 'foo' => null, + 'foo-bar' => false, + 'foo-baz' => false, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'value-with-dashes' => array( + ' [--bar=]', + array('abc',), + array( + 'foo-bar-baz' => 'abc', + 'foo' => null, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + + 'value-optional-with-dashes' => array( + '[] [--bar=]', + array('abc'), + array( + 'foo-bar-baz' => 'abc', + 'foo' => null, + 'bar' => null, + 'baz' => null, + 'something' => null, + ) + ), + 'value-optional-with-dashes2' => array( + '[] [--bar=]', + array('--bar','abc'), + array( + 'foo-bar-baz' => null, + 'foo' => null, + 'bar' => 'abc', + 'baz' => null, + 'something' => null, + ) + ), + + + ); + } + + /** + * @dataProvider routeProvider + * @param string $routeDefinition + * @param array $arguments + * @param array|null $params + */ + public function testMatching($routeDefinition, array $arguments = array(), array $params = null) + { + array_unshift($arguments, 'scriptname.php'); + $request = new ConsoleRequest($arguments); + $route = new Simple($routeDefinition); + $match = $route->match($request); + + if ($params === null) { + $this->assertNull($match, "The route must not match"); + } else { + $this->assertInstanceOf('Zend\Mvc\Router\Console\RouteMatch', $match, "The route matches"); + + foreach ($params as $key => $value) { + $this->assertEquals( + $value, + $match->getParam($key), + $value === null ? "Param $key is not present" : "Param $key is present and is equal to $value" + ); + } + } + } + + public function testCanNotMatchingWithEmtpyMandatoryParam() + { + $arguments = array('--foo='); + array_unshift($arguments, 'scriptname.php'); + $request = new ConsoleRequest($arguments); + $route = new Simple('--foo='); + $match = $route->match($request); + $this->assertEquals(null, $match); + } /** * @dataProvider routeProvider @@ -67,36 +933,108 @@ public function testFactory() ); } - public function testMatchReturnsRouteMatch() + public static function routeDefaultsProvider() { - $arguments = array('--foo=bar'); - array_unshift($arguments, 'scriptname.php'); - $request = new ConsoleRequest($arguments); - $route = new Simple('--foo='); - $match = $route->match($request); - $this->assertInstanceOf('Zend\Mvc\Router\Console\RouteMatch', $match, "The route matches"); - $this->assertEquals('bar', $match->getParam('foo')); + return array( + 'required-literals-no-defaults' => array( + 'create controller', + array(), + array('create', 'controller'), + array('create' => null, 'controller' => null), + ), + 'required-literals-defaults' => array( + 'create controller', + array('controller' => 'value'), + array('create', 'controller'), + array('create' => null, 'controller' => 'value'), + ), + 'value-param-no-defaults' => array( + 'create controller ', + array(), + array('create', 'controller', 'foo'), + array('create' => null, 'controller' => 'foo'), + ), + 'value-param-defaults-overridden' => array( + 'create controller ', + array('controller' => 'defaultValue'), + array('create', 'controller', 'foo'), + array('create' => null, 'controller' => 'foo'), + ), + 'optional-value-param-defaults' => array( + 'create controller []', + array('controller' => 'defaultValue'), + array('create', 'controller'), + array('create' => null, 'controller' => 'defaultValue'), + ), + 'alternative-literal-non-present' => array( + '(foo | bar)', + array('bar' => 'something'), + array('foo'), + array('foo' => true, 'bar' => false), + ), + 'alternative-literal-present' => array( + '(foo | bar)', + array('bar' => 'something'), + array('bar'), + array('foo' => false, 'bar' => 'something'), + ), + 'alternative-flag-non-present' => array( + '(--foo | --bar)', + array('bar' => 'something'), + array('--foo'), + array('foo' => true, 'bar' => false), + ), + 'alternative-flag-present' => array( + '(--foo | --bar)', + array('bar' => 'something'), + array('--bar'), + array('foo' => false, 'bar' => 'something'), + ), + 'optional-literal-non-present' => array( + 'foo [bar]', + array('bar' => 'something'), + array('foo'), + array('foo' => null, 'bar' => false), + ), + 'optional-literal-present' => array( + 'foo [bar]', + array('bar' => 'something'), + array('foo', 'bar'), + array('foo' => null, 'bar' => 'something'), + ), + ); } - public function testCustomRouteMatcherCanBeInjectedViaConstructor() - { - $arguments = array('--foo=bar'); + /** + * @dataProvider routeDefaultsProvider + * @param string $routeDefinition + * @param array $defaults + * @param array $arguments + * @param array|null $params + */ + public function testMatchingWithDefaults( + $routeDefinition, + array $defaults = array(), + array $arguments = array(), + array $params = null + ) { array_unshift($arguments, 'scriptname.php'); $request = new ConsoleRequest($arguments); + $route = new Simple($routeDefinition, array(), $defaults); + $match = $route->match($request); - $routeMatcher = $this->getMock('Zend\Console\RouteMatcher\RouteMatcherInterface', array('match')); - $routeMatcher->expects($this->once())->method('match') - ->with(array('--foo=bar')); - - $route = new Simple($routeMatcher); - $route->match($request); - } - - public function testConstructorThrowsExceptionWhenFirstArgumentIsNotStringNorRouteMatcherInterface() - { - $this->setExpectedException('Zend\Mvc\Exception\InvalidArgumentException'); + if ($params === null) { + $this->assertNull($match, "The route must not match"); + } else { + $this->assertInstanceOf('Zend\Mvc\Router\Console\RouteMatch', $match, "The route matches"); - new Simple(new \stdClass()); + foreach ($params as $key => $value) { + $this->assertSame( + $value, + $match->getParam($key), + $value === null ? "Param $key is not present" : "Param $key is present and is equal to '$value'" + ); + } + } } - } diff --git a/tests/ZendTest/Mvc/View/Console/DefaultRenderingStrategyTest.php b/tests/ZendTest/Mvc/View/Console/DefaultRenderingStrategyTest.php index 24cb1eb0c9a..b16ba1e1537 100644 --- a/tests/ZendTest/Mvc/View/Console/DefaultRenderingStrategyTest.php +++ b/tests/ZendTest/Mvc/View/Console/DefaultRenderingStrategyTest.php @@ -15,11 +15,8 @@ use Zend\EventManager\EventManager; use Zend\Mvc\MvcEvent; use Zend\Mvc\View\Console\DefaultRenderingStrategy; -use Zend\ServiceManager\ServiceManager; use Zend\Stdlib\Response; use Zend\View\Model; -use ZendTest\Console\TestAssets\ConsoleAdapter; -use ZendTest\ModuleManager\TestAsset\MockApplication; /** * @category Zend @@ -68,16 +65,7 @@ public function testCanDetachListenersFromEventManager() public function testIgnoresNonConsoleModelNotContainingResultKeyWhenObtainingResult() { - //Register console service - $sm = new ServiceManager(); - $sm->setService('console', new ConsoleAdapter()); - - $mockApplication = new MockApplication; - $mockApplication->setServiceManager($sm); - $event = new MvcEvent(); - $event->setApplication($mockApplication); - $model = new Model\ViewModel(array('content' => 'Page not found')); $response = new Response(); $event->setResult($model); diff --git a/tests/ZendTest/Navigation/Page/UriTest.php b/tests/ZendTest/Navigation/Page/UriTest.php index f0b17b3c040..380d31cc505 100644 --- a/tests/ZendTest/Navigation/Page/UriTest.php +++ b/tests/ZendTest/Navigation/Page/UriTest.php @@ -12,7 +12,6 @@ use Zend\Navigation\Page; use Zend\Navigation; -use Zend\Http\Request; /** * Tests the class Zend_Navigation_Page_Uri @@ -91,40 +90,6 @@ public function testGetHref() $this->assertEquals($uri, $page->getHref()); } - public function testIsActiveReturnsTrueWhenHasMatchingRequestUri() - { - $page = new Page\Uri(array( - 'label' => 'foo', - 'uri' => '/bar' - )); - - $request = new Request(); - $request->setUri('/bar'); - $request->setMethod('GET'); - - $page->setRequest($request); - - $this->assertInstanceOf('Zend\Http\Request', $page->getRequest()); - - $this->assertTrue($page->isActive()); - } - - public function testIsActiveReturnsFalseOnNonMatchingRequestUri() - { - $page = new Page\Uri(array( - 'label' => 'foo', - 'uri' => '/bar' - )); - - $request = new Request(); - $request->setUri('/baz'); - $request->setMethod('GET'); - - $page->setRequest($request); - - $this->assertFalse($page->isActive()); - } - /** * @group ZF-8922 */ diff --git a/tests/ZendTest/Paginator/Adapter/DbTableGatewayTest.php b/tests/ZendTest/Paginator/Adapter/DbTableGatewayTest.php index 1c178cbcf55..2c78502f4bf 100644 --- a/tests/ZendTest/Paginator/Adapter/DbTableGatewayTest.php +++ b/tests/ZendTest/Paginator/Adapter/DbTableGatewayTest.php @@ -10,7 +10,6 @@ namespace ZendTest\Paginator\Adapter; -use Zend\Db\Adapter\Platform\Sql92; use Zend\Paginator\Adapter\DbTableGateway; use Zend\Paginator\Adapter\DbSelect; use Zend\Db\ResultSet\ResultSet; @@ -26,7 +25,6 @@ class DbTableGatewayTest extends \PHPUnit_Framework_TestCase /** @var DbTableGateway */ protected $dbTableGateway; - /** @var \Zend\Db\TableGateway\TableGateway */ protected $mockTableGateway; public function setup() @@ -36,12 +34,13 @@ public function setup() $mockDriver->expects($this->any()) ->method('createStatement') ->will($this->returnValue($mockStatement)); - $mockDriver->expects($this->any()) - ->method('formatParameterName') - ->will($this->returnArgument(0)); + $mockPlatform = $this->getMock('Zend\Db\Adapter\Platform\PlatformInterface'); + $mockPlatform->expects($this->any()) + ->method('getName') + ->will($this->returnValue('platform')); $mockAdapter = $this->getMockForAbstractClass( 'Zend\Db\Adapter\Adapter', - array($mockDriver, new Sql92()) + array($mockDriver, $mockPlatform) ); $tableName = 'foobar'; @@ -101,47 +100,4 @@ public function testGetItemsWithWhereAndOrder() $items = $this->dbTableGateway->getItems(2, 10); $this->assertInstanceOf('Zend\Db\ResultSet\ResultSet', $items); } - - public function testGetItemsWithWhereAndOrderAndGroup() - { - $where = "foo = bar"; - $order = "foo"; - $group = "foo"; - $this->dbTableGateway = new DbTableGateway($this->mockTableGateway, $where, $order, $group); - - $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); - $this->mockStatement - ->expects($this->once()) - ->method('setSql') - ->with($this->equalTo('SELECT "foobar".* FROM "foobar" WHERE foo = bar GROUP BY "foo" ORDER BY "foo" ASC LIMIT limit OFFSET offset')); - $this->mockStatement - ->expects($this->any()) - ->method('execute') - ->will($this->returnValue($mockResult)); - - $items = $this->dbTableGateway->getItems(2, 10); - $this->assertInstanceOf('Zend\Db\ResultSet\ResultSet', $items); - } - - public function testGetItemsWithWhereAndOrderAndGroupAndHaving() - { - $where = "foo = bar"; - $order = "foo"; - $group = "foo"; - $having = "count(foo)>0"; - $this->dbTableGateway = new DbTableGateway($this->mockTableGateway, $where, $order, $group, $having); - - $mockResult = $this->getMock('Zend\Db\Adapter\Driver\ResultInterface'); - $this->mockStatement - ->expects($this->once()) - ->method('setSql') - ->with($this->equalTo('SELECT "foobar".* FROM "foobar" WHERE foo = bar GROUP BY "foo" HAVING count(foo)>0 ORDER BY "foo" ASC LIMIT limit OFFSET offset')); - $this->mockStatement - ->expects($this->any()) - ->method('execute') - ->will($this->returnValue($mockResult)); - - $items = $this->dbTableGateway->getItems(2, 10); - $this->assertInstanceOf('Zend\Db\ResultSet\ResultSet', $items); - } } diff --git a/tests/ZendTest/Stdlib/Hydrator/HydratorAwareTraitTest.php b/tests/ZendTest/Stdlib/Hydrator/HydratorAwareTraitTest.php deleted file mode 100644 index a6b5c6e9661..00000000000 --- a/tests/ZendTest/Stdlib/Hydrator/HydratorAwareTraitTest.php +++ /dev/null @@ -1,45 +0,0 @@ -getObjectForTrait('\Zend\Stdlib\Hydrator\HydratorAwareTrait'); - - $this->assertAttributeEquals(null, 'hydrator', $object); - - $hydrator = $this->getMockForAbstractClass('\Zend\Stdlib\Hydrator\AbstractHydrator'); - - $object->setHydrator($hydrator); - - $this->assertAttributeEquals($hydrator, 'hydrator', $object); - } - - public function testGetHydrator() - { - $object = $this->getObjectForTrait('\Zend\Stdlib\Hydrator\HydratorAwareTrait'); - - $this->assertNull($object->getHydrator()); - - $hydrator = $this->getMockForAbstractClass('\Zend\Stdlib\Hydrator\AbstractHydrator'); - - $object->setHydrator($hydrator); - - $this->assertEquals($hydrator, $object->getHydrator()); - } -} diff --git a/tests/ZendTest/Tag/Cloud/CloudTest.php b/tests/ZendTest/Tag/Cloud/CloudTest.php index 31e80427333..613296eb04f 100644 --- a/tests/ZendTest/Tag/Cloud/CloudTest.php +++ b/tests/ZendTest/Tag/Cloud/CloudTest.php @@ -10,7 +10,6 @@ namespace ZendTest\Tag\Cloud; -use stdClass; use Zend\Tag; use Zend\Tag\Cloud; use Zend\Tag\Cloud\DecoratorPluginManager; @@ -30,31 +29,28 @@ class CloudTest extends \PHPUnit_Framework_TestCase public function testGetAndSetItemList() { $cloud = $this->_getCloud(); - $this->assertInstanceOf('Zend\Tag\ItemList', $cloud->getItemList()); + $this->assertTrue($cloud->getItemList() instanceof Tag\ItemList); $cloud->setItemList(new ItemListDummy); - $this->assertInstanceOf('ZendTest\Tag\Cloud\ItemListDummy', $cloud->getItemList()); + $this->assertTrue($cloud->getItemList() instanceof ItemListDummy); } public function testSetCloudDecoratorViaArray() { $cloud = $this->_getCloud(); - $cloud->setCloudDecorator(array( - 'decorator' => 'CloudDummy', - 'options' => array('foo' => 'bar'), - )); - $this->assertInstanceOf('ZendTest\Tag\Cloud\TestAsset\CloudDummy', $cloud->getCloudDecorator()); + $cloud->setCloudDecorator(array('decorator' => 'CloudDummy', 'options' => array('foo' => 'bar'))); + $this->assertTrue($cloud->getCloudDecorator() instanceof TestAsset\CloudDummy); $this->assertEquals('bar', $cloud->getCloudDecorator()->getFoo()); } public function testGetAndSetCloudDecorator() { $cloud = $this->_getCloud(); - $this->assertInstanceOf('Zend\Tag\Cloud\Decorator\HtmlCloud', $cloud->getCloudDecorator()); + $this->assertTrue($cloud->getCloudDecorator() instanceof \Zend\Tag\Cloud\Decorator\HtmlCloud); $cloud->setCloudDecorator(new TestAsset\CloudDummy()); - $this->assertInstanceOf('ZendTest\Tag\Cloud\TestAsset\CloudDummy', $cloud->getCloudDecorator()); + $this->assertTrue($cloud->getCloudDecorator() instanceof TestAsset\CloudDummy); } public function testSetInvalidCloudDecorator() @@ -62,28 +58,25 @@ public function testSetInvalidCloudDecorator() $cloud = $this->_getCloud(); $this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'DecoratorInterface'); - $cloud->setCloudDecorator(new stdClass()); + $cloud->setCloudDecorator(new \stdClass()); } public function testSetTagDecoratorViaArray() { $cloud = $this->_getCloud(); - $cloud->setTagDecorator(array( - 'decorator' => 'TagDummy', - 'options' => array('foo' => 'bar'), - )); - $this->assertInstanceOf('ZendTest\Tag\Cloud\TestAsset\TagDummy', $cloud->getTagDecorator()); + $cloud->setTagDecorator(array('decorator' => 'TagDummy', 'options' => array('foo' => 'bar'))); + $this->assertTrue($cloud->getTagDecorator() instanceof TestAsset\TagDummy); $this->assertEquals('bar', $cloud->getTagDecorator()->getFoo()); } public function testGetAndSetTagDecorator() { $cloud = $this->_getCloud(); - $this->assertInstanceOf('Zend\Tag\Cloud\Decorator\HtmlTag', $cloud->getTagDecorator()); + $this->assertTrue($cloud->getTagDecorator() instanceof \Zend\Tag\Cloud\Decorator\HtmlTag); $cloud->setTagDecorator(new TestAsset\TagDummy()); - $this->assertInstanceOf('ZendTest\Tag\Cloud\TestAsset\TagDummy', $cloud->getTagDecorator()); + $this->assertTrue($cloud->getTagDecorator() instanceof TestAsset\TagDummy); } public function testSetInvalidTagDecorator() @@ -91,7 +84,7 @@ public function testSetInvalidTagDecorator() $cloud = $this->_getCloud(); $this->setExpectedException('Zend\Tag\Exception\InvalidArgumentException', 'DecoratorInterface'); - $cloud->setTagDecorator(new stdClass()); + $cloud->setTagDecorator(new \stdClass()); } public function testSetDecoratorPluginManager() @@ -105,10 +98,7 @@ public function testSetDecoratorPluginManager() public function testSetDecoratorPluginManagerViaOptions() { $decorators = new DecoratorPluginManager(); - $cloud = $this->_getCloud( - array('decoratorPluginManager' => $decorators), - null - ); + $cloud = $this->_getCloud(array('decoratorPluginManager' => $decorators), null); $this->assertSame($decorators, $cloud->getDecoratorPluginManager()); } @@ -117,10 +107,7 @@ public function testAppendTagAsArray() $cloud = $this->_getCloud(); $list = $cloud->getItemList(); - $cloud->appendTag(array( - 'title' => 'foo', - 'weight' => 1, - )); + $cloud->appendTag(array('title' => 'foo', 'weight' => 1)); $this->assertEquals('foo', $list[0]->getTitle()); } @@ -130,10 +117,7 @@ public function testAppendTagAsItem() $cloud = $this->_getCloud(); $list = $cloud->getItemList(); - $cloud->appendTag(new Tag\Item(array( - 'title' => 'foo', - 'weight' => 1, - ))); + $cloud->appendTag(new Tag\Item(array('title' => 'foo', 'weight' => 1))); $this->assertEquals('foo', $list[0]->getTitle()); } @@ -151,16 +135,8 @@ public function testSetTagsAsArray() $cloud = $this->_getCloud(); $list = $cloud->getItemList(); - $cloud->setTags(array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - array( - 'title' => 'bar', - 'weight' => 2, - ) - )); + $cloud->setTags(array(array('title' => 'foo', 'weight' => 1), + array('title' => 'bar', 'weight' => 2))); $this->assertEquals('foo', $list[0]->getTitle()); $this->assertEquals('bar', $list[1]->getTitle()); @@ -171,16 +147,8 @@ public function testSetTagsAsItem() $cloud = $this->_getCloud(); $list = $cloud->getItemList(); - $cloud->setTags(array( - new Tag\Item( array( - 'title' => 'foo', - 'weight' => 1, - )), - new Tag\Item( array( - 'title' => 'bar', - 'weight' => 2, - )), - )); + $cloud->setTags(array(new Tag\Item(array('title' => 'foo', 'weight' => 1)), + new Tag\Item(array('title' => 'bar', 'weight' => 2)))); $this->assertEquals('foo', $list[0]->getTitle()); $this->assertEquals('bar', $list[1]->getTitle()); @@ -191,16 +159,8 @@ public function testSetTagsMixed() $cloud = $this->_getCloud(); $list = $cloud->getItemList(); - $cloud->setTags(array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - new Tag\Item(array( - 'title' => 'bar', - 'weight' => 2, - )), - )); + $cloud->setTags(array(array('title' => 'foo', 'weight' => 1), + new Tag\Item(array('title' => 'bar', 'weight' => 2)))); $this->assertEquals('foo', $list[0]->getTitle()); $this->assertEquals('bar', $list[1]->getTitle()); @@ -216,14 +176,7 @@ public function testSetInvalidTags() public function testConstructorWithArray() { - $cloud = $this->_getCloud(array( - 'tags' => array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - ), - )); + $cloud = $this->_getCloud(array('tags' => array(array('title' => 'foo', 'weight' => 1)))); $list = $cloud->getItemList(); $this->assertEquals('foo', $list[0]->getTitle()); @@ -231,14 +184,7 @@ public function testConstructorWithArray() public function testConstructorWithConfig() { - $cloud = $this->_getCloud( new \Zend\Config\Config(array( - 'tags' => array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - ), - ))); + $cloud = $this->_getCloud(new \Zend\Config\Config(array('tags' => array(array('title' => 'foo', 'weight' => 1))))); $list = $cloud->getItemList(); $this->assertEquals('foo', $list[0]->getTitle()); @@ -247,15 +193,8 @@ public function testConstructorWithConfig() public function testSetOptions() { $cloud = $this->_getCloud(); - $cloud->setOptions(array( - 'tags' => array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - ), - )); - $list = $cloud->getItemList(); + $cloud->setOptions(array('tags' => array(array('title' => 'foo', 'weight' => 1)))); + $list = $cloud->getItemList(); $this->assertEquals('foo', $list[0]->getTitle()); } @@ -268,22 +207,11 @@ public function testSkipOptions() public function testRender() { - $cloud = $this->_getCloud(array( - 'tags' => array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - array( - 'title' => 'bar', - 'weight' => 3, - ), - ), - )); - $expected = '

'; + $cloud = $this->_getCloud(array('tags' => array(array('title' => 'foo', 'weight' => 1), array('title' => 'bar', 'weight' => 3)))); + $expected = ''; $this->assertEquals($expected, $cloud->render()); } @@ -295,51 +223,28 @@ public function testRenderEmptyCloud() public function testRenderViaToString() { - $cloud = $this->_getCloud(array( - 'tags' => array( - array( - 'title' => 'foo', - 'weight' => 1, - ), - array( - 'title' => 'bar', - 'weight' => 3, - ), - ), - )); - $expected = ''; - $this->assertEquals($expected, (string)$cloud); + $cloud = $this->_getCloud(array('tags' => array(array('title' => 'foo', 'weight' => 1), array('title' => 'bar', 'weight' => 3)))); + $expected = ''; + $this->assertEquals($expected, (string) $cloud); } - protected function _getCloud( - $options = null, - $setDecoratorPluginManager = true - ) { + protected function _getCloud($options = null, $setDecoratorPluginManager = true) + { $cloud = new Tag\Cloud($options); if ($setDecoratorPluginManager) { $decorators = $cloud->getDecoratorPluginManager(); - $decorators->setInvokableClass( - 'clouddummy', 'ZendTest\Tag\Cloud\TestAsset\CloudDummy' - ); - $decorators->setInvokableClass( - 'clouddummy1', 'ZendTest\Tag\Cloud\TestAsset\CloudDummy1' - ); - $decorators->setInvokableClass( - 'clouddummy2', 'ZendTest\Tag\Cloud\TestAsset\CloudDummy2' - ); - $decorators->setInvokableClass( - 'tagdummy', 'ZendTest\Tag\Cloud\TestAsset\TagDummy' - ); + $decorators->setInvokableClass('clouddummy', 'ZendTest\Tag\Cloud\TestAsset\CloudDummy'); + $decorators->setInvokableClass('clouddummy1', 'ZendTest\Tag\Cloud\TestAsset\CloudDummy1'); + $decorators->setInvokableClass('clouddummy2', 'ZendTest\Tag\Cloud\TestAsset\CloudDummy2'); + $decorators->setInvokableClass('tagdummy', 'ZendTest\Tag\Cloud\TestAsset\TagDummy'); } return $cloud; } } -class ItemListDummy extends Tag\ItemList -{ -} +class ItemListDummy extends Tag\ItemList {} diff --git a/tests/ZendTest/Tag/Cloud/Decorator/HtmlCloudTest.php b/tests/ZendTest/Tag/Cloud/Decorator/HtmlCloudTest.php index a2ea521fc2e..a5b941d46a7 100644 --- a/tests/ZendTest/Tag/Cloud/Decorator/HtmlCloudTest.php +++ b/tests/ZendTest/Tag/Cloud/Decorator/HtmlCloudTest.php @@ -25,36 +25,15 @@ public function testDefaultOutput() { $decorator = new Decorator\HtmlCloud(); - $this->assertEquals( - '
    foo bar
', - $decorator->render( - array( - 'foo', - 'bar' - ) - ) - ); + $this->assertEquals('
    foo bar
', $decorator->render(array('foo', 'bar'))); } public function testNestedTags() { $decorator = new Decorator\HtmlCloud(); - $decorator->setHtmlTags( - array( - 'span', - 'div' => array('id' => 'tag-cloud') - ) - ); + $decorator->setHtmlTags(array('span', 'div' => array('id' => 'tag-cloud'))); - $this->assertEquals( - '
foo bar
', - $decorator->render( - array( - 'foo', - 'bar' - ) - ) - ); + $this->assertEquals('
foo bar
', $decorator->render(array('foo', 'bar'))); } public function testSeparator() @@ -62,73 +41,29 @@ public function testSeparator() $decorator = new Decorator\HtmlCloud(); $decorator->setSeparator('-'); - $this->assertEquals( - '
    foo-bar
', - $decorator->render( - array( - 'foo', - 'bar' - ) - ) - ); + $this->assertEquals('
    foo-bar
', $decorator->render(array('foo', 'bar'))); } public function testConstructorWithArray() { - $decorator = new Decorator\HtmlCloud(array( - 'htmlTags' => array('div'), - 'separator' => ' ' - )); - - $this->assertEquals( - '
foo bar
', $decorator->render( - array( - 'foo', - 'bar' - ) - ) - ); + $decorator = new Decorator\HtmlCloud(array('htmlTags' => array('div'), 'separator' => ' ')); + + $this->assertEquals('
foo bar
', $decorator->render(array('foo', 'bar'))); } public function testConstructorWithConfig() { - $decorator = new Decorator\HtmlCloud( - new \Zend\Config\Config( - array( - 'htmlTags' => array('div'), - 'separator' => ' ' - ) - ) - ); + $decorator = new Decorator\HtmlCloud(new \Zend\Config\Config(array('htmlTags' => array('div'), 'separator' => ' '))); - $this->assertEquals( - '
foo bar
', $decorator->render( - array( - 'foo', - 'bar' - ) - ) - ); + $this->assertEquals('
foo bar
', $decorator->render(array('foo', 'bar'))); } public function testSetOptions() { $decorator = new Decorator\HtmlCloud(); - $decorator->setOptions( - array( - 'htmlTags' => array('div'), - 'separator' => ' ' - ) - ); + $decorator->setOptions(array('htmlTags' => array('div'), 'separator' => ' ')); - $this->assertEquals( - '
foo bar
', $decorator->render( - array( - 'foo', - 'bar' - ) - ) - ); + $this->assertEquals('
foo bar
', $decorator->render(array('foo', 'bar'))); } public function testSkipOptions() @@ -144,11 +79,9 @@ public function invalidHtmlTagProvider() array(array('&foo')), array(array(' foo')), array(array(' foo')), - array( - array( - '_foo' => array(), - ) - ), + array(array( + '_foo' => array(), + )), ); } @@ -159,36 +92,28 @@ public function testInvalidHtmlTagsRaiseAnException($tags) { $decorator = new Decorator\HtmlCloud(); $decorator->setHTMLTags($tags); - $this->setExpectedException( - 'Zend\Tag\Exception\InvalidElementNameException' - ); + $this->setExpectedException('Zend\Tag\Exception\InvalidElementNameException'); $decorator->render(array()); } public function invalidAttributeProvider() { return array( - array( - array( - 'foo' => array( - '&bar' => 'baz', - ), - ) - ), - array( - array( - 'foo' => array( - ':bar&baz' => 'bat', - ), - ) - ), - array( - array( - 'foo' => array( - 'bar/baz' => 'bat', - ), - ) - ), + array(array( + 'foo' => array( + '&bar' => 'baz', + ), + )), + array(array( + 'foo' => array( + ':bar&baz' => 'bat', + ), + )), + array(array( + 'foo' => array( + 'bar/baz' => 'bat', + ), + )), ); } @@ -199,9 +124,7 @@ public function testInvalidAttributeNamesRaiseAnException($tags) { $decorator = new Decorator\HtmlCloud(); $decorator->setHTMLTags($tags); - $this->setExpectedException( - 'Zend\Tag\Exception\InvalidAttributeNameException' - ); + $this->setExpectedException('Zend\Tag\Exception\InvalidAttributeNameException'); $decorator->render(array()); } } diff --git a/tests/ZendTest/Validator/File/IsCompressedTest.php b/tests/ZendTest/Validator/File/IsCompressedTest.php index dd0e71c2cdc..690fd4eea9f 100644 --- a/tests/ZendTest/Validator/File/IsCompressedTest.php +++ b/tests/ZendTest/Validator/File/IsCompressedTest.php @@ -33,11 +33,6 @@ protected function getMagicMime() return __DIR__ . '/_files/magic.lte.5.3.10.mime'; } - // Ubuntu has backported the changes in 12.04 to PHP 5.3.10. - if (strpos(PHP_VERSION, 'ubuntu') !== false && version_compare(PHP_VERSION, '5.3.10', '>=')) { - return __DIR__ . '/_files/magic.lte.5.3.10.mime'; - } - return __DIR__ . '/_files/magic.mime'; } diff --git a/tests/ZendTest/Validator/File/IsImageTest.php b/tests/ZendTest/Validator/File/IsImageTest.php index 2ffa7552c6c..e7bcea6ec37 100644 --- a/tests/ZendTest/Validator/File/IsImageTest.php +++ b/tests/ZendTest/Validator/File/IsImageTest.php @@ -31,11 +31,6 @@ protected function getMagicMime() return __DIR__ . '/_files/magic.lte.5.3.10.mime'; } - // Ubuntu has backported the changes in 12.04 to PHP 5.3.10. - if (strpos(PHP_VERSION, 'ubuntu') !== false && version_compare(PHP_VERSION, '5.3.10', '>=')) { - return __DIR__ . '/_files/magic.lte.5.3.10.mime'; - } - return __DIR__ . '/_files/magic.mime'; } diff --git a/tests/ZendTest/Validator/NotEmptyTest.php b/tests/ZendTest/Validator/NotEmptyTest.php index 51c770e609d..2319d869794 100644 --- a/tests/ZendTest/Validator/NotEmptyTest.php +++ b/tests/ZendTest/Validator/NotEmptyTest.php @@ -483,7 +483,7 @@ public function testSettingFalseType() */ public function testGetType() { - $this->assertEquals($this->validator->getDefaultType(), $this->validator->getType()); + $this->assertEquals(493, $this->validator->getType()); } /** @@ -593,21 +593,7 @@ public function testEqualsMessageTemplates() public function testTypeAutoDetectionHasNoSideEffect() { $validator = new NotEmpty(array('translatorEnabled' => true)); - $this->assertEquals($validator->getDefaultType(), $validator->getType()); - } - - public function testDefaultType() - { - $this->assertSame( - NotEmpty::BOOLEAN - | NotEmpty::FLOAT - | NotEmpty::STRING - | NotEmpty::EMPTY_ARRAY - | NotEmpty::NULL - | NotEmpty::SPACE - | NotEmpty::OBJECT, - $this->validator->getDefaultType() - ); + $this->assertEquals(493, $validator->getType()); } } diff --git a/tests/ZendTest/Version/VersionTest.php b/tests/ZendTest/Version/VersionTest.php index 62a6779d45d..1ece36333d7 100644 --- a/tests/ZendTest/Version/VersionTest.php +++ b/tests/ZendTest/Version/VersionTest.php @@ -8,7 +8,6 @@ * @package Zend_VersionTest.php */ -use Zend\Http; use Zend\Version\Version; /** @@ -55,10 +54,7 @@ public function testVersionCompare() } /** - * Run in separate process to avoid Version::$latestParameter caching - * * @group ZF-10363 - * @runInSeparateProcess */ public function testFetchLatestVersion() { @@ -68,18 +64,12 @@ public function testFetchLatestVersion() if (!extension_loaded('openssl')) { $this->markTestSkipped('This test requires openssl extension to be enabled in PHP'); } - $actual = Version::getLatest(); $this->assertRegExp('/^[1-2](\.[0-9]+){2}/', $actual); } - /** - * Run in separate process to avoid Version::$latestParameter caching - * - * @runInSeparateProcess - */ - public function testFetchLatestGithubVersion() + public function testFetchLatestZENDVersion() { if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) { $this->markTestSkipped('Version online tests are not enabled'); @@ -87,96 +77,8 @@ public function testFetchLatestGithubVersion() if (!extension_loaded('openssl')) { $this->markTestSkipped('This test requires openssl extension to be enabled in PHP'); } - - $actual = Version::getLatest(Version::VERSION_SERVICE_GITHUB); + $actual = Version::getLatest('ZEND'); $this->assertRegExp('/^[1-2](\.[0-9]+){2}/', $actual); } - - /** - * Run in separate process to avoid Version::$latestParameter caching - * - * @expectedException PHPUnit_Framework_Error_Warning - * @runInSeparateProcess - */ - public function testFetchLatestVersionWarnsIfAllowUrlFopenIsDisabled() - { - if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) { - $this->markTestSkipped('Version online tests are not enabled'); - } - if (ini_get('allow_url_fopen')) { - $this->markTestSkipped('Test only works with allow_url_fopen disabled'); - } - - $actual = Version::getLatest(Version::VERSION_SERVICE_ZEND); - } - - /** - * Run in separate process to avoid Version::$latestParameter caching - * - * @expectedException PHPUnit_Framework_Error_Warning - * @runInSeparateProcess - */ - public function testFetchLatestVersionWarnsIfBadServiceIsPassed() - { - if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) { - $this->markTestSkipped('Version online tests are not enabled'); - } - - $actual = Version::getLatest('bogus service'); - } - - /** - * Run in separate process to avoid Version::$latestParameter caching - * - * @runInSeparateProcess - */ - public function testFetchLatestVersionUsesSuppliedZendHttpClient() - { - if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) { - $this->markTestSkipped('Version online tests are not enabled'); - } - if (!extension_loaded('openssl')) { - $this->markTestSkipped('This test requires openssl extension to be enabled in PHP'); - } - - $httpClient = new Http\Client( - 'http://example.com', - array( - 'sslverifypeer' => false, - ) - ); - - $actual = Version::getLatest(Version::VERSION_SERVICE_GITHUB, $httpClient); - $this->assertRegExp('/^[1-2](\.[0-9]+){2}/', $actual); - - $lastRequest = $httpClient->getRequest(); - $this->assertContains('github.com', (string) $lastRequest->getUri()); - } - - /** - * Run in separate process to avoid Version::$latestParameter caching - * - * @runInSeparateProcess - */ - public function testFetchLatestVersionDoesNotThrowZendHttpClientException() - { - if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) { - $this->markTestSkipped('Version online tests are not enabled'); - } - if (!extension_loaded('openssl')) { - $this->markTestSkipped('This test requires openssl extension to be enabled in PHP'); - } - - $httpClient = new Http\Client( - 'http://example.com', - array( - 'sslcapath' => '/dev/null', - 'sslverifypeer' => true, - ) - ); - - $actual = Version::getLatest(Version::VERSION_SERVICE_GITHUB, $httpClient); - $this->assertEquals('not available', $actual); - } } diff --git a/tests/ZendTest/View/Helper/FlashMessengerTest.php b/tests/ZendTest/View/Helper/FlashMessengerTest.php index 3c2cf99851e..e742e3c8078 100644 --- a/tests/ZendTest/View/Helper/FlashMessengerTest.php +++ b/tests/ZendTest/View/Helper/FlashMessengerTest.php @@ -46,7 +46,6 @@ public function seedMessages() $helper->addMessage('bar'); $helper->addInfoMessage('bar-info'); $helper->addSuccessMessage('bar-success'); - $helper->addWarningMessage('bar-warning'); $helper->addErrorMessage('bar-error'); unset($helper); } @@ -74,7 +73,6 @@ public function testCanRetrieveMessages() $this->assertFalse($helper()->hasMessages()); $this->assertFalse($helper()->hasInfoMessages()); $this->assertFalse($helper()->hasSuccessMessages()); - $this->assertFalse($helper()->hasWarningMessages()); $this->assertFalse($helper()->hasErrorMessages()); $this->seedMessages(); @@ -82,13 +80,11 @@ public function testCanRetrieveMessages() $this->assertTrue(count($helper('default')) > 0); $this->assertTrue(count($helper('info')) > 0); $this->assertTrue(count($helper('success')) > 0); - $this->assertTrue(count($helper('warning')) > 0); $this->assertTrue(count($helper('error')) > 0); $this->assertTrue($this->plugin->hasMessages()); $this->assertTrue($this->plugin->hasInfoMessages()); $this->assertTrue($this->plugin->hasSuccessMessages()); - $this->assertTrue($this->plugin->hasWarningMessages()); $this->assertTrue($this->plugin->hasErrorMessages()); } @@ -97,7 +93,6 @@ public function testCanProxyAndRetrieveMessagesFromPluginController() $this->assertFalse($this->helper->hasMessages()); $this->assertFalse($this->helper->hasInfoMessages()); $this->assertFalse($this->helper->hasSuccessMessages()); - $this->assertFalse($this->helper->hasWarningMessages()); $this->assertFalse($this->helper->hasErrorMessages()); $this->seedMessages(); @@ -105,7 +100,6 @@ public function testCanProxyAndRetrieveMessagesFromPluginController() $this->assertTrue($this->helper->hasMessages()); $this->assertTrue($this->helper->hasInfoMessages()); $this->assertTrue($this->helper->hasSuccessMessages()); - $this->assertTrue($this->helper->hasWarningMessages()); $this->assertTrue($this->helper->hasErrorMessages()); } diff --git a/tests/ZendTest/View/Helper/HeadLinkTest.php b/tests/ZendTest/View/Helper/HeadLinkTest.php index df295f03c07..0c82b8c653c 100644 --- a/tests/ZendTest/View/Helper/HeadLinkTest.php +++ b/tests/ZendTest/View/Helper/HeadLinkTest.php @@ -277,32 +277,6 @@ public function testConditionalStylesheetCreationOccursWhenRequested() $this->assertContains('', $string); } - public function testConditionalStylesheetCreationNoIE() - { - $this->helper->setStylesheet('/styles.css', 'screen', '!IE'); - $item = $this->helper->getValue(); - $this->assertObjectHasAttribute('conditionalStylesheet', $item); - $this->assertEquals('!IE', $item->conditionalStylesheet); - - $string = $this->helper->toString(); - $this->assertContains('/styles.css', $string); - $this->assertContains('<', $string); - $this->assertContains('', $string); - } - - public function testConditionalStylesheetCreationNoIEWidthSpaces() - { - $this->helper->setStylesheet('/styles.css', 'screen', '! IE'); - $item = $this->helper->getValue(); - $this->assertObjectHasAttribute('conditionalStylesheet', $item); - $this->assertEquals('! IE', $item->conditionalStylesheet); - - $string = $this->helper->toString(); - $this->assertContains('/styles.css', $string); - $this->assertContains('<', $string); - $this->assertContains('', $string); - } - public function testSettingAlternateWithTooFewArgsRaisesException() { try { diff --git a/tests/ZendTest/View/Helper/HeadMetaTest.php b/tests/ZendTest/View/Helper/HeadMetaTest.php index 878aa679a14..b78eeda5f54 100644 --- a/tests/ZendTest/View/Helper/HeadMetaTest.php +++ b/tests/ZendTest/View/Helper/HeadMetaTest.php @@ -530,19 +530,4 @@ public function testConditional() $this->assertRegExp("|$|", $html); } - public function testConditionalNoIE() - { - $html = $this->helper->appendHttpEquiv('foo', 'bar', array('conditional' => '!IE'))->toString(); - - $this->assertContains('<', $html); - $this->assertContains('', $html); - } - - public function testConditionalNoIEWidthSpace() - { - $html = $this->helper->appendHttpEquiv('foo', 'bar', array('conditional' => '! IE'))->toString(); - - $this->assertContains('<', $html); - $this->assertContains('', $html); - } } diff --git a/tests/ZendTest/View/Helper/HeadScriptTest.php b/tests/ZendTest/View/Helper/HeadScriptTest.php index b1e25409a24..c70cfa02d41 100644 --- a/tests/ZendTest/View/Helper/HeadScriptTest.php +++ b/tests/ZendTest/View/Helper/HeadScriptTest.php @@ -379,30 +379,6 @@ public function testConditionalScriptWidthIndentation() $this->assertContains(' <', $test); - $this->assertContains('', $test); - } - - public function testConditionalScriptNoIEWidthSpace() - { - $this->helper->setAllowArbitraryAttributes(true); - $this->helper->appendFile( - '/js/foo.js', 'text/javascript', array('conditional' => '! IE') - ); - $test = $this->helper->toString(); - - $this->assertContains('<', $test); - $this->assertContains('', $test); - } - /** * @issue ZF-5435 */ diff --git a/tests/ZendTest/View/Helper/HeadStyleTest.php b/tests/ZendTest/View/Helper/HeadStyleTest.php index dd8a9a47220..d707c1aea60 100644 --- a/tests/ZendTest/View/Helper/HeadStyleTest.php +++ b/tests/ZendTest/View/Helper/HeadStyleTest.php @@ -362,28 +362,6 @@ public function testConditionalScript() $this->assertContains('<', $test); - $this->assertContains('', $test); - } - - public function testConditionalScriptNoIEWidthSpace() - { - $this->helper->appendStyle(' -a { - display: none; -}', array('media' => 'screen,projection', 'conditional' => '! IE')); - $test = $this->helper->toString(); - $this->assertContains('<', $test); - $this->assertContains('', $test); - } - /** * @issue ZF-5435 */