From f1acd2300399f79236f040d61bafca0ef56a01eb Mon Sep 17 00:00:00 2001 From: thomas Date: Tue, 28 Apr 2009 10:23:49 +0000 Subject: [PATCH 001/123] [DOCUMENTATION] English: - fixed title tags git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15234 44c647ce-9c0f-0410-b52a-842ac1e357ba --- .coveralls.yml | 3 + .gitattributes | 6 + .gitignore | 14 + .php_cs | 43 + .travis.yml | 35 + CONTRIBUTING.md | 229 ++++ LICENSE.txt | 27 + README.md | 8 + composer.json | 41 + phpunit.xml.dist | 46 + phpunit.xml.travis | 46 + src/AutoDiscover.php | 485 +++++++ src/AutoDiscover/Exception.php | 30 + src/Client.php | 1117 +++++++++++++++++ src/Client/Common.php | 75 ++ src/Client/DotNet.php | 94 ++ src/Client/Exception.php | 35 + src/Client/Local.php | 92 ++ src/Server.php | 961 ++++++++++++++ src/Server/Exception.php | 37 + src/Wsdl.php | 582 +++++++++ src/Wsdl/Exception.php | 25 + src/Wsdl/Strategy/Abstract.php | 63 + src/Wsdl/Strategy/AnyType.php | 47 + src/Wsdl/Strategy/ArrayOfTypeComplex.php | 134 ++ src/Wsdl/Strategy/ArrayOfTypeSequence.php | 150 +++ src/Wsdl/Strategy/Composite.php | 174 +++ src/Wsdl/Strategy/DefaultComplexType.php | 71 ++ src/Wsdl/Strategy/Interface.php | 40 + test/AllTests.php | 44 + test/AutoDiscover/OnlineTest.php | 57 + test/AutoDiscoverTest.php | 781 ++++++++++++ test/ClientTest.php | 509 ++++++++ test/ServerTest.php | 1049 ++++++++++++++++ test/Wsdl/AllTests.php | 21 + test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 224 ++++ test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 151 +++ test/Wsdl/CompositeStrategyTest.php | 139 ++ test/Wsdl/DefaultComplexTypeTest.php | 60 + test/Wsdl/ElementTest.php | 217 ++++ test/Wsdl/ParserTest.php | 159 +++ test/WsdlTest.php | 647 ++++++++++ test/_files/cert_file | 0 test/_files/commontypes.php | 338 +++++ test/_files/fulltests/server1.php | 61 + test/_files/fulltests/server2.php | 42 + test/_files/wsdl_documentation.wsdl | 106 ++ test/_files/wsdl_example.wsdl | 2 + test/bootstrap.php | 34 + test/schemas/wsdl.xsd | 310 +++++ 50 files changed, 9661 insertions(+) create mode 100644 .coveralls.yml create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .php_cs create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpunit.xml.dist create mode 100644 phpunit.xml.travis create mode 100644 src/AutoDiscover.php create mode 100644 src/AutoDiscover/Exception.php create mode 100644 src/Client.php create mode 100644 src/Client/Common.php create mode 100644 src/Client/DotNet.php create mode 100644 src/Client/Exception.php create mode 100644 src/Client/Local.php create mode 100644 src/Server.php create mode 100644 src/Server/Exception.php create mode 100644 src/Wsdl.php create mode 100644 src/Wsdl/Exception.php create mode 100644 src/Wsdl/Strategy/Abstract.php create mode 100644 src/Wsdl/Strategy/AnyType.php create mode 100644 src/Wsdl/Strategy/ArrayOfTypeComplex.php create mode 100644 src/Wsdl/Strategy/ArrayOfTypeSequence.php create mode 100644 src/Wsdl/Strategy/Composite.php create mode 100644 src/Wsdl/Strategy/DefaultComplexType.php create mode 100644 src/Wsdl/Strategy/Interface.php create mode 100644 test/AllTests.php create mode 100644 test/AutoDiscover/OnlineTest.php create mode 100644 test/AutoDiscoverTest.php create mode 100644 test/ClientTest.php create mode 100644 test/ServerTest.php create mode 100644 test/Wsdl/AllTests.php create mode 100644 test/Wsdl/ArrayOfTypeComplexStrategyTest.php create mode 100644 test/Wsdl/ArrayOfTypeSequenceStrategyTest.php create mode 100644 test/Wsdl/CompositeStrategyTest.php create mode 100644 test/Wsdl/DefaultComplexTypeTest.php create mode 100644 test/Wsdl/ElementTest.php create mode 100644 test/Wsdl/ParserTest.php create mode 100644 test/WsdlTest.php create mode 100644 test/_files/cert_file create mode 100644 test/_files/commontypes.php create mode 100644 test/_files/fulltests/server1.php create mode 100644 test/_files/fulltests/server2.php create mode 100644 test/_files/wsdl_documentation.wsdl create mode 100644 test/_files/wsdl_example.wsdl create mode 100644 test/bootstrap.php create mode 100644 test/schemas/wsdl.xsd diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000..53bda829 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +coverage_clover: clover.xml +json_path: coveralls-upload.json +src_dir: src diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..85dc9a8c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/test export-ignore +/vendor export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.travis.yml export-ignore +.php_cs export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4cac0a21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.buildpath +.DS_Store +.idea +.project +.settings/ +.*.sw* +.*.un~ +nbproject +tmp/ + +clover.xml +coveralls-upload.json +phpunit.xml +vendor diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..bf4b799f --- /dev/null +++ b/.php_cs @@ -0,0 +1,43 @@ +notPath('TestAsset') + ->notPath('_files') + ->filter(function (SplFileInfo $file) { + if (strstr($file->getPath(), 'compatibility')) { + return false; + } + }); +$config = Symfony\CS\Config\Config::create(); +$config->level(null); +$config->fixers( + array( + 'braces', + 'duplicate_semicolon', + 'elseif', + 'empty_return', + 'encoding', + 'eof_ending', + 'function_call_space', + 'function_declaration', + 'indentation', + 'join_function', + 'line_after_namespace', + 'linefeed', + 'lowercase_keywords', + 'parenthesis', + 'multiple_use', + 'method_argument_space', + 'object_operator', + 'php_closing_tag', + 'psr0', + 'remove_lines_between_uses', + 'short_tag', + 'standardize_not_equal', + 'trailing_spaces', + 'unused_use', + 'visibility', + 'whitespacy_lines', + ) +); +$config->finder($finder); +return $config; diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..fe909ecb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +sudo: false + +language: php + +matrix: + fast_finish: true + include: + - php: 5.5 + - php: 5.6 + env: + - EXECUTE_TEST_COVERALLS=true + - EXECUTE_CS_CHECK=true + - php: 7 + - php: hhvm + allow_failures: + - php: 7 + - php: hhvm + +notifications: + irc: "irc.freenode.org#zftalk.dev" + email: false + +before_install: + - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi + +install: + - composer install --no-interaction --prefer-source + +script: + - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit -c phpunit.xml.travis --coverage-clover clover.xml ; fi + - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit -c phpunit.xml.travis ; fi + - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run --config-file=.php_cs ; fi + +after_script: + - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d3c01ae7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,229 @@ +# CONTRIBUTING + +## RESOURCES + +If you wish to contribute to Zend Framework, please be sure to +read/subscribe to the following resources: + + - [Coding Standards](https://github.com/zendframework/zf2/wiki/Coding-Standards) + - [Contributor's Guide](http://framework.zend.com/participate/contributor-guide) + - ZF Contributor's mailing list: + Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html + Subscribe: zf-contributors-subscribe@lists.zend.com + - ZF Contributor's IRC channel: + #zftalk.dev on Freenode.net + +If you are working on new features or refactoring [create a proposal](https://github.com/zendframework/zend-soap/issues/new). + +## Reporting Potential Security Issues + +If you have encountered a potential security vulnerability, please **DO NOT** report it on the public +issue tracker: send it to us at [zf-security@zend.com](mailto:zf-security@zend.com) instead. +We will work with you to verify the vulnerability and patch it as soon as possible. + +When reporting issues, please provide the following information: + +- Component(s) affected +- A description indicating how to reproduce the issue +- A summary of the security vulnerability and impact + +We request that you contact us via the email address above and give the project +contributors a chance to resolve the vulnerability and issue a new release prior +to any public exposure; this helps protect users and provides them with a chance +to upgrade and/or update in order to protect their applications. + +For sensitive email communications, please use [our PGP key](http://framework.zend.com/zf-security-pgp-key.asc). + +## RUNNING TESTS + +> ### Note: testing versions prior to 2.4 +> +> This component originates with Zend Framework 2. During the lifetime of ZF2, +> testing infrastructure migrated from PHPUnit 3 to PHPUnit 4. In most cases, no +> changes were necessary. However, due to the migration, tests may not run on +> versions < 2.4. As such, you may need to change the PHPUnit dependency if +> attempting a fix on such a version. + +To run tests: + +- Clone the repository: + + ```console + $ git clone git@github.com:zendframework/zend-soap.git + $ cd + ``` + +- Install dependencies via composer: + + ```console + $ curl -sS https://getcomposer.org/installer | php -- + $ ./composer.phar install + ``` + + If you don't have `curl` installed, you can also download `composer.phar` from https://getcomposer.org/ + +- Run the tests via `phpunit` and the provided PHPUnit config, like in this example: + + ```console + $ ./vendor/bin/phpunit + ``` + +You can turn on conditional tests with the phpunit.xml file. +To do so: + + - Copy `phpunit.xml.dist` file to `phpunit.xml` + - Edit `phpunit.xml` to enable any specific functionality you + want to test, as well as to provide test values to utilize. + +## Running Coding Standards Checks + +This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding +standards checks, and provides configuration for our selected checks. +`php-cs-fixer` is installed by default via Composer. + +To run checks only: + +```console +$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs +``` + +To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run` +flag: + +```console +$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs +``` + +If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure +they pass, and make sure you add and commit the changes after verification. + +## Recommended Workflow for Contributions + +Your first step is to establish a public repository from which we can +pull your work into the master repository. We recommend using +[GitHub](https://github.com), as that is where the component is already hosted. + +1. Setup a [GitHub account](http://github.com/), if you haven't yet +2. Fork the repository (http://github.com/zendframework/zend-soap) +3. Clone the canonical repository locally and enter it. + + ```console + $ git clone git://github.com:zendframework/zend-soap.git + $ cd zend-soap + ``` + +4. Add a remote to your fork; substitute your GitHub username in the command + below. + + ```console + $ git remote add {username} git@github.com:{username}/zend-soap.git + $ git fetch {username} + ``` + +### Keeping Up-to-Date + +Periodically, you should update your fork or personal repository to +match the canonical ZF repository. Assuming you have setup your local repository +per the instructions above, you can do the following: + + +```console +$ git checkout master +$ git fetch origin +$ git rebase origin/master +# OPTIONALLY, to keep your remote up-to-date - +$ git push {username} master:master +``` + +If you're tracking other branches -- for example, the "develop" branch, where +new feature development occurs -- you'll want to do the same operations for that +branch; simply substitute "develop" for "master". + +### Working on a patch + +We recommend you do each new feature or bugfix in a new branch. This simplifies +the task of code review as well as the task of merging your changes into the +canonical repository. + +A typical workflow will then consist of the following: + +1. Create a new local branch based off either your master or develop branch. +2. Switch to your new local branch. (This step can be combined with the + previous step with the use of `git checkout -b`.) +3. Do some work, commit, repeat as necessary. +4. Push the local branch to your remote repository. +5. Send a pull request. + +The mechanics of this process are actually quite trivial. Below, we will +create a branch for fixing an issue in the tracker. + +```console +$ git checkout -b hotfix/9295 +Switched to a new branch 'hotfix/9295' +``` + +... do some work ... + + +```console +$ git commit +``` + +... write your log message ... + + +```console +$ git push {username} hotfix/9295:hotfix/9295 +Counting objects: 38, done. +Delta compression using up to 2 threads. +Compression objects: 100% (18/18), done. +Writing objects: 100% (20/20), 8.19KiB, done. +Total 20 (delta 12), reused 0 (delta 0) +To ssh://git@github.com/{username}/zend-soap.git + b5583aa..4f51698 HEAD -> master +``` + +To send a pull request, you have two options. + +If using GitHub, you can do the pull request from there. Navigate to +your repository, select the branch you just created, and then select the +"Pull Request" button in the upper right. Select the user/organization +"zendframework" as the recipient. + +If using your own repository - or even if using GitHub - you can use `git +format-patch` to create a patchset for us to apply; in fact, this is +**recommended** for security-related patches. If you use `format-patch`, please +send the patches as attachments to: + +- zf-devteam@zend.com for patches without security implications +- zf-security@zend.com for security patches + +#### What branch to issue the pull request against? + +Which branch should you issue a pull request against? + +- For fixes against the stable release, issue the pull request against the + "master" branch. +- For new features, or fixes that introduce new elements to the public API (such + as new public methods or properties), issue the pull request against the + "develop" branch. + +### Branch Cleanup + +As you might imagine, if you are a frequent contributor, you'll start to +get a ton of branches both locally and on your remote. + +Once you know that your changes have been accepted to the master +repository, we suggest doing some cleanup of these branches. + +- Local branch cleanup + + ```console + $ git branch -d + ``` + +- Remote branch removal + + ```console + $ git push {username} : + ``` diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..6eab5aa1 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Copyright (c) 2005-2015, Zend Technologies USA, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of Zend Technologies USA, Inc. nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..d3096d1f --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# zend-soap + +`Zend\Soap` is a component to manage the [SOAP](http://en.wikipedia.org/wiki/SOAP) +protocol in order to design client or server PHP application. + + +- File issues at https://github.com/zendframework/zend-soap/issues +- Documentation is at http://framework.zend.com/manual/current/en/index.html#zend-soap diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..6311044c --- /dev/null +++ b/composer.json @@ -0,0 +1,41 @@ +{ + "name": "zendframework/zend-soap", + "description": "Zend\\Soap component", + "license": "BSD-3-Clause", + "keywords": [ + "zf2", + "soap" + ], + "homepage": "https://github.com/zendframework/zend-soap", + "autoload": { + "psr-4": { + "Zend\\Soap\\": "src/" + } + }, + "require": { + "php": ">=5.3.23", + "zendframework/zend-server": "self.version", + "zendframework/zend-stdlib": "self.version", + "zendframework/zend-uri": "self.version" + }, + "require-dev": { + "zendframework/zend-http": "self.version", + "fabpot/php-cs-fixer": "1.7.*", + "satooshi/php-coveralls": "dev-master", + "phpunit/PHPUnit": "~4.0" + }, + "suggest": { + "zendframework/zend-http": "Zend\\Http component" + }, + "extra": { + "branch-alias": { + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" + } + }, + "autoload-dev": { + "psr-4": { + "ZendTest\\Soap\\": "test/" + } + } +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..66e3db04 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,46 @@ + + + + + ./test/ + + + + + + disable + + + + + + ./src + + + + + + + + + + + + + diff --git a/phpunit.xml.travis b/phpunit.xml.travis new file mode 100644 index 00000000..66e3db04 --- /dev/null +++ b/phpunit.xml.travis @@ -0,0 +1,46 @@ + + + + + ./test/ + + + + + + disable + + + + + + ./src + + + + + + + + + + + + + diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php new file mode 100644 index 00000000..ab53d2a3 --- /dev/null +++ b/src/AutoDiscover.php @@ -0,0 +1,485 @@ + 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"); + + /** + * soap:operation style + * + * @var array + */ + protected $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http'); + + /** + * Constructor + * + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @param string|Zend_Uri $uri + */ + public function __construct($strategy = true, $uri=null) + { + $this->_reflection = new Zend_Server_Reflection(); + $this->setComplexTypeStrategy($strategy); + + if($uri !== null) { + $this->setUri($uri); + } + } + + /** + * Set the location at which the WSDL file will be availabe. + * + * @see Zend_Soap_Exception + * @throws Zend_Soap_AutoDiscover_Exception + * @param Zend_Uri|string $uri + * @return Zend_Soap_AutoDiscover + */ + public function setUri($uri) + { + if(!is_string($uri) && !($uri instanceof Zend_Uri)) { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance."); + } + $this->_uri = $uri; + + // change uri in WSDL file also if existant + if($this->_wsdl instanceof Zend_Soap_Wsdl) { + $this->_wsdl->setUri($uri); + } + + return $this; + } + + /** + * Return the current Uri that the SOAP WSDL Service will be located at. + * + * @return Zend_Uri + */ + public function getUri() + { + if($this->_uri !== null) { + $uri = $this->_uri; + } else { + $schema = $this->getSchema(); + $host = $this->getHostName(); + $scriptName = $this->getRequestUriWithoutParameters(); + $uri = Zend_Uri::factory($schema . '://' . $host . $scriptName); + $this->setUri($uri); + } + return $uri; + } + + /** + * Set options for all the binding operations soap:body elements. + * + * By default the options are set to 'use' => 'encoded' and + * 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/". + * + * @see Zend_Soap_AutoDiscover_Exception + * @param array $operationStyle + * @return Zend_Soap_AutoDiscover + */ + public function setOperationBodyStyle(array $operationStyle=array()) + { + if(!isset($operationStyle['use'])) { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("Key 'use' is required in Operation soap:body style."); + } + $this->_operationBodyStyle = $operationStyle; + return $this; + } + + /** + * Set Binding soap:binding style. + * + * By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'. + * + * @param array $bindingStyle + * @return Zend_Soap_AutoDiscover + */ + public function setBindingStyle(array $bindingStyle=array()) + { + if(isset($bindingStyle['style'])) { + $this->_bindingStyle['style'] = $bindingStyle['style']; + } + if(isset($bindingStyle['transport'])) { + $this->_bindingStyle['transport'] = $bindingStyle['transport']; + } + return $this; + } + + /** + * Detect and returns the current HTTP/HTTPS Schema + * + * @return string + */ + protected function getSchema() + { + $schema = "http"; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { + $schema = 'https'; + } + return $schema; + } + + /** + * Detect and return the current hostname + * + * @return string + */ + protected function getHostName() + { + if(isset($_SERVER['HTTP_HOST'])) { + $host = $_SERVER['HTTP_HOST']; + } else { + $host = $_SERVER['SERVER_NAME']; + } + return $host; + } + + /** + * Detect and return the current script name without parameters + * + * @return string + */ + protected function getRequestUriWithoutParameters() + { + if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch + $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; + } elseif (isset($_SERVER['REQUEST_URI'])) { + $requestUri = $_SERVER['REQUEST_URI']; + } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI + $requestUri = $_SERVER['ORIG_PATH_INFO']; + } else { + $requestUri = $_SERVER['SCRIPT_NAME']; + } + if( ($pos = strpos($requestUri, "?")) !== false) { + $requestUri = substr($requestUri, 0, $pos); + } + + return $requestUri; + } + + /** + * Set the strategy that handles functions and classes that are added AFTER this call. + * + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_AutoDiscover + */ + public function setComplexTypeStrategy($strategy) + { + $this->_strategy = $strategy; + if($this->_wsdl instanceof Zend_Soap_Wsdl) { + $this->_wsdl->setComplexTypeStrategy($strategy); + } + + return $this; + } + + /** + * Set the Class the SOAP server will use + * + * @param string $class Class Name + * @param string $namespace Class Namspace - Not Used + * @param array $argv Arguments to instantiate the class - Not Used + */ + public function setClass($class, $namespace = '', $argv = null) + { + $uri = $this->getUri(); + + $wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy); + + $port = $wsdl->addPortType($class . 'Port'); + $binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port'); + + $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); + $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); + foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { + /* 's */ + $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response'); + $desc = $method->getDescription(); + if (strlen($desc) > 0) { + /** @todo check, what should be done for portoperation documentation */ + //$wsdl->addDocumentation($portOperation, $desc); + } + /* 's */ + + $this->_functions[] = $method->getName(); + + $selectedPrototype = null; + $maxNumArgumentsOfPrototype = -1; + foreach ($method->getPrototypes() as $prototype) { + $numParams = count($prototype->getParameters()); + if($numParams > $maxNumArgumentsOfPrototype) { + $maxNumArgumentsOfPrototype = $numParams; + $selectedPrototype = $prototype; + } + } + + if($selectedPrototype != null) { + $prototype = $selectedPrototype; + $args = array(); + foreach($prototype->getParameters() as $param) { + $args[$param->getName()] = $wsdl->getType($param->getType()); + } + $message = $wsdl->addMessage($method->getName() . 'Request', $args); + if (strlen($desc) > 0) { + //$wsdl->addDocumentation($message, $desc); + } + if ($prototype->getReturnType() != "void") { + $returnName = 'return'; + $message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType()))); + } + + /* 's */ + $operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); + $wsdl->addSoapOperation($operation, $uri . '#' .$method->getName()); + /* 's */ + } + } + $this->_wsdl = $wsdl; + } + + /** + * Add a Single or Multiple Functions to the WSDL + * + * @param string $function Function Name + * @param string $namespace Function namespace - Not Used + */ + public function addFunction($function, $namespace = '') + { + static $port; + static $operation; + static $binding; + + if (!is_array($function)) { + $function = (array) $function; + } + + $uri = $this->getUri(); + + if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) { + $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); + $name = $parts[0]; + $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy); + + $port = $wsdl->addPortType($name . 'Port'); + $binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port'); + + $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); + $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri); + } else { + $wsdl = $this->_wsdl; + } + + foreach ($function as $func) { + $method = $this->_reflection->reflectFunction($func); + foreach ($method->getPrototypes() as $prototype) { + $args = array(); + foreach ($prototype->getParameters() as $param) { + $args[$param->getName()] = $wsdl->getType($param->getType()); + } + $message = $wsdl->addMessage($method->getName() . 'Request', $args); + $desc = $method->getDescription(); + if (strlen($desc) > 0) { + //$wsdl->addDocumentation($message, $desc); + } + if($prototype->getReturnType() != "void") { + $returnName = "return"; + $message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType()))); + } + /* 's */ + $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response'); + if (strlen($desc) > 0) { + //$wsdl->addDocumentation($portOperation, $desc); + } + /* 's */ + + /* 's */ + $operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); + $wsdl->addSoapOperation($operation, $uri . '#' .$method->getName()); + /* 's */ + + $this->_functions[] = $method->getName(); + + // We will only add one prototype + break; + } + } + $this->_wsdl = $wsdl; + } + + /** + * Action to take when an error occurs + * + * @param string $fault + * @param string|int $code + */ + public function fault($fault = null, $code = null) + { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + } + + /** + * Handle the Request + * + * @param string $request A non-standard request - Not Used + */ + public function handle($request = false) + { + if (!headers_sent()) { + header('Content-Type: text/xml'); + } + $this->_wsdl->dump(); + } + + /** + * Proxy to WSDL dump function + * + * @param string $filename + */ + public function dump($filename) + { + if($this->_wsdl !== null) { + return $this->_wsdl->dump($filename); + } else { + /** + * @see Zend_Soap_AutoDiscover_Exception + */ + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet."); + } + } + + /** + * Proxy to WSDL toXml() function + */ + public function toXml() + { + if($this->_wsdl !== null) { + return $this->_wsdl->toXml(); + } else { + /** + * @see Zend_Soap_AutoDiscover_Exception + */ + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("Cannot return autodiscovered contents, WSDL file has not been generated yet."); + } + } + + /** + * Return an array of functions in the WSDL + * + * @return array + */ + public function getFunctions() + { + return $this->_functions; + } + + /** + * Load Functions + * + * @param unknown_type $definition + */ + public function loadFunctions($definition) + { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + } + + /** + * Set Persistance + * + * @param int $mode + */ + public function setPersistence($mode) + { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + } + + /** + * Returns an XSD Type for the given PHP type + * + * @param string $type PHP Type to get the XSD type for + * @return string + */ + public function getType($type) + { + if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) { + /** @todo Exception throwing may be more correct */ + + // WSDL is not defined yet, so we can't recognize type in context of current service + return ''; + } else { + return $this->_wsdl->getType($type); + } + } +} diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php new file mode 100644 index 00000000..144bb75b --- /dev/null +++ b/src/AutoDiscover/Exception.php @@ -0,0 +1,30 @@ + PHP class pairings for handling return/incoming values + * @var array + */ + protected $_classmap = null; + + /** + * Registered fault exceptions + * @var array + */ + protected $_faultExceptions = array(); + + /** + * SOAP version to use; SOAP_1_2 by default, to allow processing of headers + * @var int + */ + protected $_soapVersion = SOAP_1_2; + + /** Set of other SoapClient options */ + protected $_uri = null; + protected $_location = null; + protected $_style = null; + protected $_use = null; + protected $_login = null; + protected $_password = null; + protected $_proxy_host = null; + protected $_proxy_port = null; + protected $_proxy_login = null; + protected $_proxy_password = null; + protected $_local_cert = null; + protected $_passphrase = null; + protected $_compression = null; + protected $_connection_timeout = null; + protected $_stream_context = null; + protected $_features = null; + protected $_cache_wsdl = null; + + /** + * WSDL used to access server + * It also defines Zend_Soap_Client working mode (WSDL vs non-WSDL) + * + * @var string + */ + protected $_wsdl = null; + + /** + * SoapClient object + * + * @var SoapClient + */ + protected $_soapClient; + + /** + * Last invoked method + * + * @var string + */ + protected $_lastMethod = ''; + + /** + * SOAP request headers. + * + * Array of SoapHeader objects + * + * @var array + */ + protected $_soapInputHeaders = array(); + + /** + * Permanent SOAP request headers (shared between requests). + * + * Array of SoapHeader objects + * + * @var array + */ + protected $_permanentSoapInputHeaders = array(); + + /** + * Output SOAP headers. + * + * Array of SoapHeader objects + * + * @var array + */ + protected $_soapOutputHeaders = array(); + + /** + * Constructor + * + * @param string $wsdl + * @param array $options + */ + public function __construct($wsdl = null, $options = null) + { + if (!extension_loaded('soap')) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.'); + } + + if ($wsdl !== null) { + $this->setWsdl($wsdl); + } + if ($options !== null) { + $this->setOptions($options); + } + } + + /** + * Set wsdl + * + * @param string $wsdl + * @return Zend_Soap_Client + */ + public function setWsdl($wsdl) + { + $this->_wsdl = $wsdl; + $this->_soapClient = null; + + return $this; + } + + /** + * Get wsdl + * + * @return string + */ + public function getWsdl() + { + return $this->_wsdl; + } + + /** + * Set Options + * + * Allows setting options as an associative array of option => value pairs. + * + * @param array|Zend_Config $options + * @return Zend_Soap_Client + * @throws Zend_SoapClient_Exception + */ + public function setOptions($options) + { + if($options instanceof Zend_Config) { + $options = $options->toArray(); + } + + foreach ($options as $key => $value) { + switch ($key) { + case 'classmap': + case 'classMap': + $this->setClassmap($value); + break; + case 'encoding': + $this->setEncoding($value); + break; + case 'soapVersion': + case 'soap_version': + $this->setSoapVersion($value); + break; + case 'wsdl': + $this->setWsdl($value); + break; + case 'uri': + $this->setUri($value); + break; + case 'location': + $this->setLocation($value); + break; + case 'style': + $this->setStyle($value); + break; + case 'use': + $this->setEncodingMethod($value); + break; + case 'login': + $this->setHttpLogin($value); + break; + case 'password': + $this->setHttpPassword($value); + break; + case 'proxy_host': + $this->setProxyHost($value); + break; + case 'proxy_port': + $this->setProxyPort($value); + break; + case 'proxy_login': + $this->setProxyLogin($value); + break; + case 'proxy_password': + $this->setProxyPassword($value); + break; + case 'local_cert': + $this->setHttpsCertificate($value); + break; + case 'passphrase': + $this->setHttpsCertPassphrase($value); + break; + case 'compression': + $this->setCompressionOptions($value); + break; + case 'stream_context': + $this->setStreamContext($value); + break; + case 'features': + $this->setSoapFeatures($value); + break; + case 'cache_wsdl': + $this->setWsdlCache($value); + break; + + // Not used now + // case 'connection_timeout': + // $this->_connection_timeout = $value; + // break; + + default: + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Unknown SOAP client option'); + break; + } + } + + return $this; + } + + /** + * Return array of options suitable for using with SoapClient constructor + * + * @return array + */ + public function getOptions() + { + $options = array(); + + $options['classmap'] = $this->getClassmap(); + $options['encoding'] = $this->getEncoding(); + $options['soap_version'] = $this->getSoapVersion(); + $options['wsdl'] = $this->getWsdl(); + $options['uri'] = $this->getUri(); + $options['location'] = $this->getLocation(); + $options['style'] = $this->getStyle(); + $options['use'] = $this->getEncodingMethod(); + $options['login'] = $this->getHttpLogin(); + $options['password'] = $this->getHttpPassword(); + $options['proxy_host'] = $this->getProxyHost(); + $options['proxy_port'] = $this->getProxyPort(); + $options['proxy_login'] = $this->getProxyLogin(); + $options['proxy_password'] = $this->getProxyPassword(); + $options['local_cert'] = $this->getHttpsCertificate(); + $options['passphrase'] = $this->getHttpsCertPassphrase(); + $options['compression'] = $this->getCompressionOptions(); + //$options['connection_timeout'] = $this->_connection_timeout; + $options['stream_context'] = $this->getStreamContext(); + $options['cache_wsdl'] = $this->getWsdlCache(); + $options['features'] = $this->getSoapFeatures(); + + foreach ($options as $key => $value) { + if ($value == null) { + unset($options[$key]); + } + } + + return $options; + } + + /** + * Set SOAP version + * + * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid soap version argument + */ + public function setSoapVersion($version) + { + if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.'); + } + $this->_soapVersion = $version; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get SOAP version + * + * @return int + */ + public function getSoapVersion() + { + return $this->_soapVersion; + } + + /** + * Set classmap + * + * @param array $classmap + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception for any invalid class in the class map + */ + public function setClassmap(array $classmap) + { + foreach ($classmap as $type => $class) { + if (!class_exists($class)) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid class in class map'); + } + } + + $this->_classmap = $classmap; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve classmap + * + * @return mixed + */ + public function getClassmap() + { + return $this->_classmap; + } + + /** + * Set encoding + * + * @param string $encoding + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid encoding argument + */ + public function setEncoding($encoding) + { + if (!is_string($encoding)) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid encoding specified'); + } + + $this->_encoding = $encoding; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get encoding + * + * @return string + */ + public function getEncoding() + { + return $this->_encoding; + } + + /** + * Check for valid URN + * + * @param string $urn + * @return true + * @throws Zend_Soap_Client_Exception on invalid URN + */ + public function validateUrn($urn) + { + $segs = parse_url($urn); + if (isset($segs['scheme'])) { + return true; + } + + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid URN'); + } + + /** + * Set URI + * + * URI in Web Service the target namespace + * + * @param string $uri + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid uri argument + */ + public function setUri($uri) + { + $this->validateUrn($uri); + $this->_uri = $uri; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve URI + * + * @return string + */ + public function getUri() + { + return $this->_uri; + } + + /** + * Set Location + * + * URI in Web Service the target namespace + * + * @param string $location + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid uri argument + */ + public function setLocation($location) + { + $this->validateUrn($location); + $this->_location = $location; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve URI + * + * @return string + */ + public function getLocation() + { + return $this->_location; + } + + /** + * Set request style + * + * @param int $style One of the SOAP_RPC or SOAP_DOCUMENT constants + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid style argument + */ + public function setStyle($style) + { + if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); + } + + $this->_style = $style; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get request style + * + * @return int + */ + public function getStyle() + { + return $this->_style; + } + + /** + * Set message encoding method + * + * @param int $use One of the SOAP_ENCODED or SOAP_LITERAL constants + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid message encoding method argument + */ + public function setEncodingMethod($use) + { + if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); + } + + $this->_use = $use; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get message encoding method + * + * @return int + */ + public function getEncodingMethod() + { + return $this->_use; + } + + /** + * Set HTTP login + * + * @param string $login + * @return Zend_Soap_Client + */ + public function setHttpLogin($login) + { + $this->_login = $login; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve HTTP Login + * + * @return string + */ + public function getHttpLogin() + { + return $this->_login; + } + + /** + * Set HTTP password + * + * @param string $password + * @return Zend_Soap_Client + */ + public function setHttpPassword($password) + { + $this->_password = $password; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve HTTP Password + * + * @return string + */ + public function getHttpPassword() + { + return $this->_password; + } + + /** + * Set proxy host + * + * @param string $proxyHost + * @return Zend_Soap_Client + */ + public function setProxyHost($proxyHost) + { + $this->_proxy_host = $proxyHost; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve proxy host + * + * @return string + */ + public function getProxyHost() + { + return $this->_proxy_host; + } + + /** + * Set proxy port + * + * @param int $proxyPort + * @return Zend_Soap_Client + */ + public function setProxyPort($proxyPort) + { + $this->_proxy_port = (int)$proxyPort; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve proxy port + * + * @return int + */ + public function getProxyPort() + { + return $this->_proxy_port; + } + + /** + * Set proxy login + * + * @param string $proxyLogin + * @return Zend_Soap_Client + */ + public function setProxyLogin($proxyLogin) + { + $this->_proxy_login = $proxyLogin; + + $this->_soapClient = null; + + return $this; + } + + /** + * Retrieve proxy login + * + * @return string + */ + public function getProxyLogin() + { + return $this->_proxy_login; + } + + /** + * Set proxy password + * + * @param string $proxyLogin + * @return Zend_Soap_Client + */ + public function setProxyPassword($proxyPassword) + { + $this->_proxy_password = $proxyPassword; + + $this->_soapClient = null; + + return $this; + } + + /** + * Set HTTPS client certificate path + * + * @param string $localCert local certificate path + * @return Zend_Soap_Client + * @throws Zend_Soap_Client_Exception with invalid local certificate path argument + */ + public function setHttpsCertificate($localCert) + { + if (!is_readable($localCert)) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.'); + } + + $this->_local_cert = $localCert; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get HTTPS client certificate path + * + * @return string + */ + public function getHttpsCertificate() + { + return $this->_local_cert; + } + + /** + * Set HTTPS client certificate passphrase + * + * @param string $passphrase + * @return Zend_Soap_Client + */ + public function setHttpsCertPassphrase($passphrase) + { + $this->_passphrase = $passphrase; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get HTTPS client certificate passphrase + * + * @return string + */ + public function getHttpsCertPassphrase() + { + return $this->_passphrase; + } + + /** + * Set compression options + * + * @param int $compressionOptions + * @return Zend_Soap_Client + */ + public function setCompressionOptions($compressionOptions) + { + $this->_compression = $compressionOptions; + + $this->_soapClient = null; + + return $this; + } + + /** + * Get Compression options + * + * @return int + */ + public function getCompressionOptions() + { + return $this->_compression; + } + + /** + * Retrieve proxy password + * + * @return string + */ + public function getProxyPassword() + { + return $this->_proxy_password; + } + + /** + * Set Stream Context + * + * @return Zend_Soap_Client + */ + public function setStreamContext($context) + { + if(!is_resource($context) || get_resource_type($context) !== "stream-context") { + /** + * @see Zend_Soap_Client_Exception + */ + require_once "Zend/Soap/Client/Exception.php"; + throw new Zend_Soap_Client_Exception( + "Invalid stream context resource given." + ); + } + + $this->_stream_context = $context; + return $this; + } + + /** + * Get Stream Context + * + * @return resource + */ + public function getStreamContext() + { + return $this->_stream_context; + } + + /** + * Set the SOAP Feature options. + * + * @param string|int $feature + * @return Zend_Soap_Client + */ + public function setSoapFeatures($feature) + { + $this->_features = $feature; + return $this; + } + + /** + * Return current SOAP Features options + * + * @return int + */ + public function getSoapFeatures() + { + return $this->_features; + } + + /** + * Set the SOAP Wsdl Caching Options + * + * @param string|int|boolean $caching + * @return Zend_Soap_Client + */ + public function setWsdlCache($options) + { + $this->_cache_wsdl = $options; + return $this; + } + + /** + * Get current SOAP Wsdl Caching option + */ + public function getWsdlCache() + { + return $this->_cache_wsdl; + } + + /** + * Retrieve request XML + * + * @return string + */ + public function getLastRequest() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastRequest(); + } + + return ''; + } + + /** + * Get response XML + * + * @return string + */ + public function getLastResponse() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastResponse(); + } + + return ''; + } + + /** + * Retrieve request headers + * + * @return string + */ + public function getLastRequestHeaders() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastRequestHeaders(); + } + + return ''; + } + + /** + * Retrieve response headers (as string) + * + * @return string + */ + public function getLastResponseHeaders() + { + if ($this->_soapClient !== null) { + return $this->_soapClient->__getLastResponseHeaders(); + } + + return ''; + } + + /** + * Retrieve last invoked method + * + * @return string + */ + public function getLastMethod() + { + return $this->_lastMethod; + } + + /** + * Do request proxy method. + * + * May be overridden in subclasses + * + * @internal + * @param Zend_Soap_Client_Common $client + * @param string $request + * @param string $location + * @param string $action + * @param int $version + * @param int $one_way + * @return mixed + */ + public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) + { + // Perform request as is + if ($one_way == null) { + return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version); + } else { + return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way); + } + } + + /** + * Initialize SOAP Client object + * + * @throws Zend_Soap_Client_Exception + */ + protected function _initSoapClientObject() + { + $wsdl = $this->getWsdl(); + $options = array_merge($this->getOptions(), array('trace' => true)); + + if ($wsdl == null) { + if (!isset($options['location'])) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.'); + } + if (!isset($options['uri'])) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.'); + } + } else { + if (isset($options['use'])) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.'); + } + if (isset($options['style'])) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.'); + } + } + unset($options['wsdl']); + + $this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options); + } + + + /** + * Perform arguments pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + */ + protected function _preProcessArguments($arguments) + { + // Do nothing + return $arguments; + } + + /** + * Perform result pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + */ + protected function _preProcessResult($result) + { + // Do nothing + return $result; + } + + /** + * Add SOAP input header + * + * @param SoapHeader $header + * @param boolean $permanent + * @return Zend_Soap_Client + */ + public function addSoapInputHeader(SoapHeader $header, $permanent = false) + { + if ($permanent) { + $this->_permanentSoapInputHeaders[] = $header; + } else { + $this->_soapInputHeaders[] = $header; + } + + return $this; + } + + /** + * Reset SOAP input headers + * + * @return Zend_Soap_Client + */ + public function resetSoapInputHeaders() + { + $this->_permanentSoapInputHeaders = array(); + $this->_soapInputHeaders = array(); + + return $this; + } + + /** + * Get last SOAP output headers + * + * @return array + */ + public function getLastSoapOutputHeaderObjects() + { + return $this->_soapOutputHeaders; + } + + /** + * Perform a SOAP call + * + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call($name, $arguments) + { + if ($this->_soapClient == null) { + $this->_initSoapClientObject(); + } + + $this->_lastMethod = $name; + + $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders); + $result = $this->_soapClient->__soapCall($name, + $this->_preProcessArguments($arguments), + null, /* Options are already set to the SOAP client object */ + (count($soapHeaders) > 0)? $soapHeaders : null, + $this->_soapOutputHeaders); + + // Reset non-permanent input headers + $this->_soapInputHeaders = array(); + + return $this->_preProcessResult($result); + } + + + /** + * Return a list of available functions + * + * @return array + * @throws Zend_Soap_Client_Exception + */ + public function getFunctions() + { + if ($this->getWsdl() == null) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); + } + + if ($this->_soapClient == null) { + $this->_initSoapClientObject(); + } + + return $this->_soapClient->__getFunctions(); + } + + + /** + * Get used types. + * + * @return array + */ + + /** + * Return a list of SOAP types + * + * @return array + * @throws Zend_Soap_Client_Exception + */ + public function getTypes() + { + if ($this->getWsdl() == null) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); + } + + if ($this->_soapClient == null) { + $this->_initSoapClientObject(); + } + + return $this->_soapClient->__getTypes(); + } +} diff --git a/src/Client/Common.php b/src/Client/Common.php new file mode 100644 index 00000000..02ee9352 --- /dev/null +++ b/src/Client/Common.php @@ -0,0 +1,75 @@ +_doRequestCallback = $doRequestCallback; + + parent::__construct($wsdl, $options); + } + + /** + * Performs SOAP request over HTTP. + * Overridden to implement different transport layers, perform additional XML processing or other purpose. + * + * @param string $request + * @param string $location + * @param string $action + * @param int $version + * @param int $one_way + * @return mixed + */ + function __doRequest($request, $location, $action, $version, $one_way = null) + { + if ($one_way === null) { + return call_user_func($this->_doRequestCallback, $this, $request, $location, $action, $version); + } else { + return call_user_func($this->_doRequestCallback, $this, $request, $location, $action, $version, $one_way); + } + } + +} + +} // end if (extension_loaded('soap') diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php new file mode 100644 index 00000000..e0d085cc --- /dev/null +++ b/src/Client/DotNet.php @@ -0,0 +1,94 @@ +setSoapVersion(SOAP_1_1); + + parent::__construct($wsdl, $options); + } + + + /** + * Perform arguments pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + * @throws Zend_Soap_Client_Exception + */ + protected function _preProcessArguments($arguments) + { + if (count($arguments) > 1 || + (count($arguments) == 1 && !is_array(reset($arguments))) + ) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); + } + + // Do nothing + return array($arguments); + } + + /** + * Perform result pre-processing + * + * My be overridden in descendant classes + * + * @param array $arguments + */ + protected function _preProcessResult($result) + { + $resultProperty = $this->getLastMethod() . 'Result'; + + return $result->$resultProperty; + } + +} + +} // end if (extension_loaded('soap') diff --git a/src/Client/Exception.php b/src/Client/Exception.php new file mode 100644 index 00000000..5dafac0c --- /dev/null +++ b/src/Client/Exception.php @@ -0,0 +1,35 @@ +_server = $server; + + // Use Server specified SOAP version as default + $this->setSoapVersion($server->getSoapVersion()); + + parent::__construct($wsdl, $options); + } + + /** + * Actual "do request" method. + * + * @internal + * @param Zend_Soap_Client_Common $client + * @param string $request + * @param string $location + * @param string $action + * @param int $version + * @param int $one_way + * @return mixed + */ + public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) + { + // Perform request as is + ob_start(); + $this->_server->handle($request); + $response = ob_get_contents(); + ob_end_clean(); + + return $response; + } +} + +} // end if (extension_loaded('soap') diff --git a/src/Server.php b/src/Server.php new file mode 100644 index 00000000..70b65de9 --- /dev/null +++ b/src/Server.php @@ -0,0 +1,961 @@ + PHP class pairings for handling return/incoming values + * @var array + */ + protected $_classmap; + + /** + * Encoding + * @var string + */ + protected $_encoding; + + /** + * SOAP Server Features + * + * @var int + */ + protected $_features; + + /** + * WSDL Caching Options of SOAP Server + * + * @var + */ + protected $_wsdlCache; + + + /** + * Registered fault exceptions + * @var array + */ + protected $_faultExceptions = array(); + + /** + * Functions registered with this server; may be either an array or the SOAP_FUNCTIONS_ALL + * constant + * @var array|int + */ + protected $_functions = array(); + + /** + * Persistence mode; should be one of the SOAP persistence constants + * @var int + */ + protected $_persistence; + + /** + * Request XML + * @var string + */ + protected $_request; + + /** + * Response XML + * @var string + */ + protected $_response; + + /** + * Flag: whether or not {@link handle()} should return a response instead + * of automatically emitting it. + * @var boolean + */ + protected $_returnResponse = false; + + /** + * SOAP version to use; SOAP_1_2 by default, to allow processing of headers + * @var int + */ + protected $_soapVersion = SOAP_1_2; + + /** + * URI or path to WSDL + * @var string + */ + protected $_wsdl; + + /** + * URI namespace for SOAP server + * @var string URI + */ + protected $_uri; + + /** + * Constructor + * + * Sets display_errors INI setting to off (prevent client errors due to bad + * XML in response). Registers {@link handlePhpErrors()} as error handler + * for E_USER_ERROR. + * + * If $wsdl is provided, it is passed on to {@link setWsdl()}; if any + * options are specified, they are passed on to {@link setOptions()}. + * + * @param string $wsdl + * @param array $options + * @return void + */ + public function __construct($wsdl = null, array $options = null) + { + if (!extension_loaded('soap')) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('SOAP extension is not loaded.'); + } + + if (null !== $wsdl) { + $this->setWsdl($wsdl); + } + + if (null !== $options) { + $this->setOptions($options); + } + } + + /** + * Set Options + * + * Allows setting options as an associative array of option => value pairs. + * + * @param array|Zend_Config $options + * @return Zend_Soap_Server + */ + public function setOptions($options) + { + if($options instanceof Zend_Config) { + $options = $options->toArray(); + } + + foreach ($options as $key => $value) { + switch ($key) { + case 'actor': + $this->setActor($value); + break; + case 'classmap': + case 'classMap': + $this->setClassmap($value); + break; + case 'encoding': + $this->setEncoding($value); + break; + case 'soapVersion': + case 'soap_version': + $this->setSoapVersion($value); + break; + case 'uri': + $this->setUri($value); + break; + case 'wsdl': + $this->setWsdl($value); + break; + case 'featues': + $this->setSoapFeatures($value); + break; + case 'cache_wsdl': + $this->setWsdlCache($value); + break; + default: + break; + } + } + + return $this; + } + + /** + * Return array of options suitable for using with SoapServer constructor + * + * @return array + */ + public function getOptions() + { + $options = array(); + if (null !== $this->_actor) { + $options['actor'] = $this->_actor; + } + + if (null !== $this->_classmap) { + $options['classmap'] = $this->_classmap; + } + + if (null !== $this->_encoding) { + $options['encoding'] = $this->_encoding; + } + + if (null !== $this->_soapVersion) { + $options['soap_version'] = $this->_soapVersion; + } + + if (null !== $this->_uri) { + $options['uri'] = $this->_uri; + } + + if(null !== $this->_features) { + $options['features'] = $this->_features; + } + + if(null !== $this->_wsdlCache) { + $options['cache_wsdl'] = $this->_wsdlCache; + } + + return $options; + } + + /** + * Set encoding + * + * @param string $encoding + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception with invalid encoding argument + */ + public function setEncoding($encoding) + { + if (!is_string($encoding)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid encoding specified'); + } + + $this->_encoding = $encoding; + return $this; + } + + /** + * Get encoding + * + * @return string + */ + public function getEncoding() + { + return $this->_encoding; + } + + /** + * Set SOAP version + * + * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception with invalid soap version argument + */ + public function setSoapVersion($version) + { + if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid soap version specified'); + } + + $this->_soapVersion = $version; + return $this; + } + + /** + * Get SOAP version + * + * @return int + */ + public function getSoapVersion() + { + return $this->_soapVersion; + } + + /** + * Check for valid URN + * + * @param string $urn + * @return true + * @throws Zend_Soap_Server_Exception on invalid URN + */ + public function validateUrn($urn) + { + $segs = parse_url($urn); + if (isset($segs['scheme'])) { + return true; + } + + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid URN'); + } + + /** + * Set actor + * + * Actor is the actor URI for the server. + * + * @param string $actor + * @return Zend_Soap_Server + */ + public function setActor($actor) + { + $this->validateUrn($actor); + $this->_actor = $actor; + return $this; + } + + /** + * Retrieve actor + * + * @return string + */ + public function getActor() + { + return $this->_actor; + } + + /** + * Set URI + * + * URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'. + * + * @param string $uri + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception with invalid uri argument + */ + public function setUri($uri) + { + $this->validateUrn($uri); + $this->_uri = $uri; + return $this; + } + + /** + * Retrieve URI + * + * @return string + */ + public function getUri() + { + return $this->_uri; + } + + /** + * Set classmap + * + * @param array $classmap + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception for any invalid class in the class map + */ + public function setClassmap($classmap) + { + if (!is_array($classmap)) { + /** + * @see Zend_Soap_Server_Exception + */ + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Classmap must be an array'); + } + foreach ($classmap as $type => $class) { + if (!class_exists($class)) { + /** + * @see Zend_Soap_Server_Exception + */ + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid class in class map'); + } + } + + $this->_classmap = $classmap; + return $this; + } + + /** + * Retrieve classmap + * + * @return mixed + */ + public function getClassmap() + { + return $this->_classmap; + } + + /** + * Set wsdl + * + * @param string $wsdl URI or path to a WSDL + * @return Zend_Soap_Server + */ + public function setWsdl($wsdl) + { + $this->_wsdl = $wsdl; + return $this; + } + + /** + * Retrieve wsdl + * + * @return string + */ + public function getWsdl() + { + return $this->_wsdl; + } + + /** + * Set the SOAP Feature options. + * + * @param string|int $feature + * @return Zend_Soap_Server + */ + public function setSoapFeatures($feature) + { + $this->_features = $feature; + return $this; + } + + /** + * Return current SOAP Features options + * + * @return int + */ + public function getSoapFeatures() + { + return $this->_features; + } + + /** + * Set the SOAP Wsdl Caching Options + * + * @param string|int|boolean $caching + * @return Zend_Soap_Server + */ + public function setWsdlCache($options) + { + $this->_wsdlCache = $options; + return $this; + } + + /** + * Get current SOAP Wsdl Caching option + */ + public function getWsdlCache() + { + return $this->_wsdlCache; + } + + /** + * Attach a function as a server method + * + * @param array|string $function Function name, array of function names to attach, + * or SOAP_FUNCTIONS_ALL to attach all functions + * @param string $namespace Ignored + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception on invalid functions + */ + public function addFunction($function, $namespace = '') + { + // Bail early if set to SOAP_FUNCTIONS_ALL + if ($this->_functions == SOAP_FUNCTIONS_ALL) { + return $this; + } + + if (is_array($function)) { + foreach ($function as $func) { + if (is_string($func) && function_exists($func)) { + $this->_functions[] = $func; + } else { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('One or more invalid functions specified in array'); + } + } + $this->_functions = array_merge($this->_functions, $function); + } elseif (is_string($function) && function_exists($function)) { + $this->_functions[] = $function; + } elseif ($function == SOAP_FUNCTIONS_ALL) { + $this->_functions = SOAP_FUNCTIONS_ALL; + } else { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid function specified'); + } + + if (is_array($this->_functions)) { + $this->_functions = array_unique($this->_functions); + } + + return $this; + } + + /** + * Attach a class to a server + * + * Accepts a class name to use when handling requests. Any additional + * arguments will be passed to that class' constructor when instantiated. + * + * @param mixed $class Class name or object instance to examine and attach + * to the server. + * @param mixed $arg1 Optional argument to pass to class constructor + * @param mixed $arg2 Optional second argument to pass to class constructor + * dispatch. + * @return Zend_Soap_Server + * @throws Zend_Soap_Server_Exception if called more than once, or if class + * does not exist + */ + public function setClass($class, $arg1 = null, $arg2 = null) + { + if (isset($this->_class)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('A class has already been registered with this soap server instance'); + } + + if (!is_string($class)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid class argument (' . gettype($class) . ')'); + } + + if (!class_exists($class)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Class "' . $class . '" does not exist'); + } + + $this->_class = $class; + if (1 < func_num_args()) { + $argv = func_get_args(); + array_shift($argv); + $this->_classArgs = $argv; + } + + return $this; + } + + /** + * Attach an object to a server + * + * Accepts an instanciated object to use when handling requests. + * + * @param object $object + * @return Zend_Soap_Server + */ + public function setObject($object) + { + if(!is_object($object)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid object argument ('.gettype($object).')'); + } + + if(isset($this->_object)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance'); + } + + $this->_object = $object; + + return $this; + } + + /** + * Return a server definition array + * + * Returns a list of all functions registered with {@link addFunction()}, + * merged with all public methods of the class set with {@link setClass()} + * (if any). + * + * @access public + * @return array + */ + public function getFunctions() + { + $functions = array(); + if (null !== $this->_class) { + $functions = get_class_methods($this->_class); + } elseif (null !== $this->_object) { + $functions = get_class_methods($this->_object); + } + + return array_merge((array) $this->_functions, $functions); + } + + /** + * Unimplemented: Load server definition + * + * @param array $array + * @return void + * @throws Zend_Soap_Server_Exception Unimplemented + */ + public function loadFunctions($definition) + { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Unimplemented'); + } + + /** + * Set server persistence + * + * @param int $mode + * @return Zend_Soap_Server + */ + public function setPersistence($mode) + { + if (!in_array($mode, array(SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST))) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid persistence mode specified'); + } + + $this->_persistence = $mode; + return $this; + } + + /** + * Get server persistence + * + * @return Zend_Soap_Server + */ + public function getPersistence() + { + return $this->_persistence; + } + + /** + * Set request + * + * $request may be any of: + * - DOMDocument; if so, then cast to XML + * - DOMNode; if so, then grab owner document and cast to XML + * - SimpleXMLElement; if so, then cast to XML + * - stdClass; if so, calls __toString() and verifies XML + * - string; if so, verifies XML + * + * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request + * @return Zend_Soap_Server + */ + private function _setRequest($request) + { + if ($request instanceof DOMDocument) { + $xml = $request->saveXML(); + } elseif ($request instanceof DOMNode) { + $xml = $request->ownerDocument->saveXML(); + } elseif ($request instanceof SimpleXMLElement) { + $xml = $request->asXML(); + } elseif (is_object($request) || is_string($request)) { + if (is_object($request)) { + $xml = $request->__toString(); + } else { + $xml = $request; + } + + $dom = new DOMDocument(); + if(strlen($xml) == 0 || !$dom->loadXML($xml)) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid XML'); + } + } + $this->_request = $xml; + return $this; + } + + /** + * Retrieve request XML + * + * @return string + */ + public function getLastRequest() + { + return $this->_request; + } + + /** + * Set return response flag + * + * If true, {@link handle()} will return the response instead of + * automatically sending it back to the requesting client. + * + * The response is always available via {@link getResponse()}. + * + * @param boolean $flag + * @return Zend_Soap_Server + */ + public function setReturnResponse($flag) + { + $this->_returnResponse = ($flag) ? true : false; + return $this; + } + + /** + * Retrieve return response flag + * + * @return boolean + */ + public function getReturnResponse() + { + return $this->_returnResponse; + } + + /** + * Get response XML + * + * @return string + */ + public function getLastResponse() + { + return $this->_response; + } + + /** + * Get SoapServer object + * + * Uses {@link $_wsdl} and return value of {@link getOptions()} to instantiate + * SoapServer object, and then registers any functions or class with it, as + * well as peristence. + * + * @return SoapServer + */ + protected function _getSoap() + { + $options = $this->getOptions(); + $server = new SoapServer($this->_wsdl, $options); + + if (!empty($this->_functions)) { + $server->addFunction($this->_functions); + } + + if (!empty($this->_class)) { + $args = $this->_classArgs; + array_unshift($args, $this->_class); + call_user_func_array(array($server, 'setClass'), $args); + } + + if (!empty($this->_object)) { + $server->setObject($this->_object); + } + + if (null !== $this->_persistence) { + $server->setPersistence($this->_persistence); + } + + return $server; + } + + /** + * Handle a request + * + * Instantiates SoapServer object with options set in object, and + * dispatches its handle() method. + * + * $request may be any of: + * - DOMDocument; if so, then cast to XML + * - DOMNode; if so, then grab owner document and cast to XML + * - SimpleXMLElement; if so, then cast to XML + * - stdClass; if so, calls __toString() and verifies XML + * - string; if so, verifies XML + * + * If no request is passed, pulls request using php:://input (for + * cross-platform compatability purposes). + * + * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request Optional request + * @return void|string + */ + public function handle($request = null) + { + if (null === $request) { + $request = file_get_contents('php://input'); + } + + // Set Zend_Soap_Server error handler + $displayErrorsOriginalState = $this->_initializeSoapErrorContext(); + + $setRequestException = null; + /** + * @see Zend_Soap_Server_Exception + */ + require_once 'Zend/Soap/Server/Exception.php'; + try { + $this->_setRequest($request); + } catch (Zend_Soap_Server_Exception $e) { + $setRequestException = $e; + } + + $soap = $this->_getSoap(); + + ob_start(); + if($setRequestException instanceof Exception) { + // Send SOAP fault message if we've catched exception + $soap->fault("Sender", $setRequestException->getMessage()); + } else { + try { + $soap->handle($request); + } catch (Exception $e) { + $fault = $this->fault($e); + $soap->fault($fault->faultcode, $fault->faultstring); + } + } + $this->_response = ob_get_clean(); + + // Restore original error handler + restore_error_handler(); + ini_set('display_errors', $displayErrorsOriginalState); + + if (!$this->_returnResponse) { + echo $this->_response; + return; + } + + return $this->_response; + } + + /** + * Method initalizes the error context that the SOAPServer enviroment will run in. + * + * @return boolean display_errors original value + */ + protected function _initializeSoapErrorContext() + { + $displayErrorsOriginalState = ini_get('display_errors'); + ini_set('display_errors', false); + set_error_handler(array($this, 'handlePhpErrors'), E_USER_ERROR); + return $displayErrorsOriginalState; + } + + /** + * Register a valid fault exception + * + * @param string|array $class Exception class or array of exception classes + * @return Zend_Soap_Server + */ + public function registerFaultException($class) + { + $this->_faultExceptions = array_merge($this->_faultExceptions, (array) $class); + return $this; + } + + /** + * Deregister a fault exception from the fault exception stack + * + * @param string $class + * @return boolean + */ + public function deregisterFaultException($class) + { + if (in_array($class, $this->_faultExceptions, true)) { + $index = array_search($class, $this->_faultExceptions); + unset($this->_faultExceptions[$index]); + return true; + } + + return false; + } + + /** + * Return fault exceptions list + * + * @return array + */ + public function getFaultExceptions() + { + return $this->_faultExceptions; + } + + /** + * Generate a server fault + * + * Note that the arguments are reverse to those of SoapFault. + * + * If an exception is passed as the first argument, its message and code + * will be used to create the fault object if it has been registered via + * {@Link registerFaultException()}. + * + * @link http://www.w3.org/TR/soap12-part1/#faultcodes + * @param string|Exception $fault + * @param string $code SOAP Fault Codes + * @return SoapFault + */ + public function fault($fault = null, $code = "Receiver") + { + if ($fault instanceof Exception) { + $class = get_class($fault); + if (in_array($class, $this->_faultExceptions)) { + $message = $fault->getMessage(); + $eCode = $fault->getCode(); + $code = empty($eCode) ? $code : $eCode; + } else { + $message = 'Unknown error'; + } + } elseif(is_string($fault)) { + $message = $fault; + } else { + $message = 'Unknown error'; + } + + $allowedFaultModes = array( + 'VersionMismatch', 'MustUnderstand', 'DataEncodingUnknown', + 'Sender', 'Receiver', 'Server' + ); + if(!in_array($code, $allowedFaultModes)) { + $code = "Receiver"; + } + + return new SoapFault($code, $message); + } + + /** + * Throw PHP errors as SoapFaults + * + * @param int $errno + * @param string $errstr + * @param string $errfile + * @param int $errline + * @param array $errcontext + * @return void + * @throws SoapFault + */ + public function handlePhpErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null) + { + throw $this->fault($errstr, "Receiver"); + } +} diff --git a/src/Server/Exception.php b/src/Server/Exception.php new file mode 100644 index 00000000..9df51f88 --- /dev/null +++ b/src/Server/Exception.php @@ -0,0 +1,37 @@ +getUri(); + } + $this->_uri = $uri; + + /** + * @todo change DomDocument object creation from cparsing to construxting using API + * It also should authomatically escape $name and $uri values if necessary + */ + $wsdl = " + "; + $this->_dom = new DOMDocument(); + if (!$this->_dom->loadXML($wsdl)) { + require_once 'Zend/Server/Exception.php'; + throw new Zend_Server_Exception('Unable to create DomDocument'); + } else { + $this->_wsdl = $this->_dom->documentElement; + } + + $this->setComplexTypeStrategy($strategy); + } + + /** + * Set a new uri for this WSDL + * + * @param string|Zend_Uri_Http $uri + * @return Zend_Server_Wsdl + */ + public function setUri($uri) + { + if ($uri instanceof Zend_Uri_Http) { + $uri = $uri->getUri(); + } + $oldUri = $this->_uri; + $this->_uri = $uri; + + if($this->_dom !== null) { + // @todo: This is the worst hack ever, but its needed due to design and non BC issues of WSDL generation + $xml = $this->_dom->saveXML(); + $xml = str_replace($oldUri, $uri, $xml); + $this->_dom = new DOMDocument(); + $this->_dom->loadXML($xml); + } + + return $this; + } + + /** + * Set a strategy for complex type detection and handling + * + * @todo Boolean is for backwards compability with extractComplexType object var. Remove it in later versions. + * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_Wsdl + */ + public function setComplexTypeStrategy($strategy) + { + if($strategy === true) { + require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; + $strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType(); + } else if($strategy === false) { + require_once "Zend/Soap/Wsdl/Strategy/AnyType.php"; + $strategy = new Zend_Soap_Wsdl_Strategy_AnyType(); + } else if(is_string($strategy)) { + if(class_exists($strategy)) { + $strategy = new $strategy(); + } else { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception( + sprintf("Strategy with name '%s does not exist.", $strategy + )); + } + } + + if(!($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface)) { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception("Set a strategy that is not of type 'Zend_Soap_Wsdl_Strategy_Interface'"); + } + $this->_strategy = $strategy; + return $this; + } + + /** + * Get the current complex type strategy + * + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getComplexTypeStrategy() + { + return $this->_strategy; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_messages message} element to the WSDL + * + * @param string $name Name for the {@link http://www.w3.org/TR/wsdl#_messages message} + * @param array $parts An array of {@link http://www.w3.org/TR/wsdl#_message parts} + * The array is constructed like: 'name of part' => 'part xml schema data type' + * @return object The new message's XML_Tree_Node for use in {@link function addDocumentation} + */ + public function addMessage($name, $parts) + { + $message = $this->_dom->createElement('message'); + + $message->setAttribute('name', $name); + + if (sizeof($parts) > 0) { + foreach ($parts as $name => $type) { + $part = $this->_dom->createElement('part'); + $part->setAttribute('name', $name); + $part->setAttribute('type', $type); + $message->appendChild($part); + } + } + + $this->_wsdl->appendChild($message); + + return $message; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_porttypes portType} element to the WSDL + * + * @param string $name portType element's name + * @return object The new portType's XML_Tree_Node for use in {@link function addPortOperation} and {@link function addDocumentation} + */ + public function addPortType($name) + { + $portType = $this->_dom->createElement('portType'); + $portType->setAttribute('name', $name); + $this->_wsdl->appendChild($portType); + + return $portType; + } + + /** + * Add an {@link http://www.w3.org/TR/wsdl#_request-response operation} element to a portType element + * + * @param object $portType a portType XML_Tree_Node, from {@link function addPortType} + * @param string $name Operation name + * @param string $input Input Message + * @param string $output Output Message + * @param string $fault Fault Message + * @return object The new operation's XML_Tree_Node for use in {@link function addDocumentation} + */ + public function addPortOperation($portType, $name, $input = false, $output = false, $fault = false) + { + $operation = $this->_dom->createElement('operation'); + $operation->setAttribute('name', $name); + + if (is_string($input) && (strlen(trim($input)) >= 1)) { + $node = $this->_dom->createElement('input'); + $node->setAttribute('message', $input); + $operation->appendChild($node); + } + if (is_string($output) && (strlen(trim($output)) >= 1)) { + $node= $this->_dom->createElement('output'); + $node->setAttribute('message', $output); + $operation->appendChild($node); + } + if (is_string($fault) && (strlen(trim($fault)) >= 1)) { + $node = $this->_dom->createElement('fault'); + $node->setAttribute('message', $fault); + $operation->appendChild($node); + } + + $portType->appendChild($operation); + + return $operation; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_bindings binding} element to WSDL + * + * @param string $name Name of the Binding + * @param string $type name of the portType to bind + * @return object The new binding's XML_Tree_Node for use with {@link function addBindingOperation} and {@link function addDocumentation} + */ + public function addBinding($name, $portType) + { + $binding = $this->_dom->createElement('binding'); + $binding->setAttribute('name', $name); + $binding->setAttribute('type', $portType); + + $this->_wsdl->appendChild($binding); + + return $binding; + } + + /** + * Add an operation to a binding element + * + * @param object $binding A binding XML_Tree_Node returned by {@link function addBinding} + * @param array $input An array of attributes for the input element, allowed keys are: 'use', 'namespace', 'encodingStyle'. {@link http://www.w3.org/TR/wsdl#_soap:body More Information} + * @param array $output An array of attributes for the output element, allowed keys are: 'use', 'namespace', 'encodingStyle'. {@link http://www.w3.org/TR/wsdl#_soap:body More Information} + * @param array $fault An array of attributes for the fault element, allowed keys are: 'name', 'use', 'namespace', 'encodingStyle'. {@link http://www.w3.org/TR/wsdl#_soap:body More Information} + * @return object The new Operation's XML_Tree_Node for use with {@link function addSoapOperation} and {@link function addDocumentation} + */ + public function addBindingOperation($binding, $name, $input = false, $output = false, $fault = false) + { + $operation = $this->_dom->createElement('operation'); + $operation->setAttribute('name', $name); + + if (is_array($input)) { + $node = $this->_dom->createElement('input'); + $soap_node = $this->_dom->createElement('soap:body'); + foreach ($input as $name => $value) { + $soap_node->setAttribute($name, $value); + } + $node->appendChild($soap_node); + $operation->appendChild($node); + } + + if (is_array($output)) { + $node = $this->_dom->createElement('output'); + $soap_node = $this->_dom->createElement('soap:body'); + foreach ($output as $name => $value) { + $soap_node->setAttribute($name, $value); + } + $node->appendChild($soap_node); + $operation->appendChild($node); + } + + if (is_array($fault)) { + $node = $this->_dom->createElement('fault'); + if (isset($fault['name'])) { + $node->setAttribute('name', $fault['name']); + } + $soap_node = $this->_dom->createElement('soap:body'); + foreach ($output as $name => $value) { + $soap_node->setAttribute($name, $value); + } + $node->appendChild($soap_node); + $operation->appendChild($node); + } + + $binding->appendChild($operation); + + return $operation; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_soap:binding SOAP binding} element to a Binding element + * + * @param object $binding A binding XML_Tree_Node returned by {@link function addBinding} + * @param string $style binding style, possible values are "rpc" (the default) and "document" + * @param string $transport Transport method (defaults to HTTP) + * @return boolean + */ + public function addSoapBinding($binding, $style = 'document', $transport = 'http://schemas.xmlsoap.org/soap/http') + { + $soap_binding = $this->_dom->createElement('soap:binding'); + $soap_binding->setAttribute('style', $style); + $soap_binding->setAttribute('transport', $transport); + + $binding->appendChild($soap_binding); + + return $soap_binding; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_soap:operation SOAP operation} to an operation element + * + * @param object $operation An operation XML_Tree_Node returned by {@link function addBindingOperation} + * @param string $soap_action SOAP Action + * @return boolean + */ + public function addSoapOperation($binding, $soap_action) + { + if ($soap_action instanceof Zend_Uri_Http) { + $soap_action = $soap_action->getUri(); + } + $soap_operation = $this->_dom->createElement('soap:operation'); + $soap_operation->setAttribute('soapAction', $soap_action); + + $binding->insertBefore($soap_operation, $binding->firstChild); + + return $soap_operation; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_services service} element to the WSDL + * + * @param string $name Service Name + * @param string $port_name Name of the port for the service + * @param string $binding Binding for the port + * @param string $location SOAP Address for the service + * @return object The new service's XML_Tree_Node for use with {@link function addDocumentation} + */ + public function addService($name, $port_name, $binding, $location) + { + if ($location instanceof Zend_Uri_Http) { + $location = $location->getUri(); + } + $service = $this->_dom->createElement('service'); + $service->setAttribute('name', $name); + + $port = $this->_dom->createElement('port'); + $port->setAttribute('name', $port_name); + $port->setAttribute('binding', $binding); + + $soap_address = $this->_dom->createElement('soap:address'); + $soap_address->setAttribute('location', $location); + + $port->appendChild($soap_address); + $service->appendChild($port); + + $this->_wsdl->appendChild($service); + + return $service; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_documentation document} element to any element in the WSDL + * + * @param object $input_node An XML_Tree_Node returned by another method to add the document to + * @param string $document Human readable documentation for the node + * @return boolean + */ + public function addDocumentation($input_node, $documentation) + { + if ($input_node === $this) { + $node = $this->_dom->documentElement; + } else { + $node = $input_node; + } + + /** @todo Check if 'documentation' is a correct name for the element (WSDL spec uses 'document') */ + $doc = $this->_dom->createElement('documentation'); + $doc_cdata = $this->_dom->createTextNode($documentation); + $doc->appendChild($doc_cdata); + $node->appendChild($doc); + + return $doc; + } + + /** + * Add WSDL Types element + * + * @param object $types A DomDocument|DomNode|DomElement|DomDocumentFragment with all the XML Schema types defined in it + */ + public function addTypes($types) + { + if ($types instanceof DomDocument) { + $dom = $this->_dom->importNode($types->documentElement); + $this->_wsdl->appendChild($types->documentElement); + } elseif ($types instanceof DomNode || $types instanceof DomElement || $types instanceof DomDocumentFragment ) { + $dom = $this->_dom->importNode($types); + $this->_wsdl->appendChild($dom); + } + } + + /** + * Add a complex type name that is part of this WSDL and can be used in signatures. + * + * @param string $type + * @return Zend_Soap_Wsdl + */ + public function addType($type) + { + if(!in_array($type, $this->_includedTypes)) { + $this->_includedTypes[] = $type; + } + return $this; + } + + /** + * Return an array of all currently included complex types + * + * @return array + */ + public function getTypes() + { + return $this->_includedTypes; + } + + /** + * Return the Schema node of the WSDL + * + * @return DOMElement + */ + public function getSchema() + { + if($this->_schema == null) { + $this->addSchemaTypeSection(); + } + + return $this->_schema; + } + + /** + * Return the WSDL as XML + * + * @return string WSDL as XML + */ + public function toXML() + { + return $this->_dom->saveXML(); + } + + /** + * Return DOM Document + * + * @return object DomDocum ent + */ + public function toDomDocument() + { + return $this->_dom; + } + + /** + * Echo the WSDL as XML + * + * @return boolean + */ + public function dump($filename = false) + { + if (!$filename) { + echo $this->toXML(); + return true; + } else { + return file_put_contents($filename, $this->toXML()); + } + } + + /** + * Returns an XSD Type for the given PHP type + * + * @param string $type PHP Type to get the XSD type for + * @return string + */ + public function getType($type) + { + switch (strtolower($type)) { + case 'string': + case 'str': + return 'xsd:string'; + break; + case 'int': + case 'integer': + return 'xsd:int'; + break; + case 'float': + case 'double': + return 'xsd:float'; + break; + case 'boolean': + case 'bool': + return 'xsd:boolean'; + break; + case 'array': + return 'soap-enc:Array'; + break; + case 'object': + return 'xsd:struct'; + break; + case 'mixed': + return 'xsd:anyType'; + break; + case 'void': + return ''; + default: + // delegate retrieval of complex type to current strategy + return $this->addComplexType($type); + } + } + + /** + * This function makes sure a complex types section and schema additions are set. + * + * @return Zend_Soap_Wsdl + */ + public function addSchemaTypeSection() + { + if ($this->_schema === null) { + $this->_schema = $this->_dom->createElement('xsd:schema'); + $this->_schema->setAttribute('targetNamespace', $this->_uri); + $types = $this->_dom->createElement('types'); + $types->appendChild($this->_schema); + $this->_wsdl->appendChild($types); + } + return $this; + } + + /** + * Add a {@link http://www.w3.org/TR/wsdl#_types types} data type definition + * + * @param string $type Name of the class to be specified + * @return string XSD Type for the given PHP type + */ + public function addComplexType($type) + { + if (in_array($type, $this->getTypes())) { + return "tns:$type"; + } + $this->addSchemaTypeSection(); + + $strategy = $this->getComplexTypeStrategy(); + $strategy->setContext($this); + // delegates the detection of a complex type to the current strategy + return $strategy->addComplexType($type); + } +} diff --git a/src/Wsdl/Exception.php b/src/Wsdl/Exception.php new file mode 100644 index 00000000..a0dbe211 --- /dev/null +++ b/src/Wsdl/Exception.php @@ -0,0 +1,25 @@ +_context = $context; + } + + /** + * Return the current Zend_Soap_Wsdl context object + * + * @return Zend_Soap_Wsdl + */ + public function getContext() + { + return $this->_context; + } +} diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php new file mode 100644 index 00000000..058c6665 --- /dev/null +++ b/src/Wsdl/Strategy/AnyType.php @@ -0,0 +1,47 @@ +_inProcess)) { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itsself."); + } + $this->_inProcess[$type] = $type; + + $nestingLevel = $this->_getNestedCount($type); + + if($nestingLevel > 1) { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception( + "ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ". + "one level. Use array object properties to return deep nested data. + "); + } + + $singularType = $this->_getSingularPhpType($type); + + if(!class_exists($singularType)) { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception(sprintf( + "Cannot add a complex type %s that is not an object or where ". + "class could not be found in 'DefaultComplexType' strategy.", $type + )); + } + + if($nestingLevel == 1) { + // The following blocks define the Array of Object structure + $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type); + } else { + $xsdComplexTypeName = $singularType; + } + + // The array for the objects has been created, now build the object definition: + if(!in_array($singularType, $this->getContext()->getTypes())) { + parent::addComplexType($singularType); + } + + unset($this->_inProcess[$type]); + return "tns:".$xsdComplexTypeName; + } + + protected function _addArrayOfComplexType($singularType, $type) + { + $dom = $this->getContext()->toDomDocument(); + + $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType); + + if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) { + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $xsdComplexTypeName); + + $complexContent = $dom->createElement("xsd:complexContent"); + $complexType->appendChild($complexContent); + + $xsdRestriction = $dom->createElement("xsd:restriction"); + $xsdRestriction->setAttribute('base', 'soap-enc:Array'); + $complexContent->appendChild($xsdRestriction); + + $xsdAttribute = $dom->createElement("xsd:attribute"); + $xsdAttribute->setAttribute("ref", "soap-enc:arrayType"); + $xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType)); + $xsdRestriction->appendChild($xsdAttribute); + + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($xsdComplexTypeName); + } + + return $xsdComplexTypeName; + } + + protected function _getXsdComplexTypeName($type) + { + return sprintf('ArrayOf%s', $type); + } + + /** + * From a nested defintion with type[], get the singular PHP Type + * + * @param string $type + * @return string + */ + protected function _getSingularPhpType($type) + { + return str_replace("[]", "", $type); + } + + /** + * Return the array nesting level based on the type name + * + * @param string $type + * @return integer + */ + protected function _getNestedCount($type) + { + return substr_count($type, "[]"); + } +} \ No newline at end of file diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php new file mode 100644 index 00000000..06579b62 --- /dev/null +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -0,0 +1,150 @@ +_getNestedCount($type); + + if($nestedCounter > 0) { + $singularType = $this->_getSingularType($type); + + for($i = 1; $i <= $nestedCounter; $i++) { + $complexTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i); + $childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1); + + $this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName); + } + // adding the PHP type which is resolved to a nested XSD type. therefore add only once. + $this->getContext()->addType($complexTypeName); + + return "tns:$complexTypeName"; + } else { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception(sprintf( + 'ArrayOfTypeSequence Strategy does not allow for complex types that are not in @return type[] syntax. "%s" type was specified.', $type + )); + } + } + + /** + * Return the ArrayOf or simple type name based on the singular xsdtype and the nesting level + * + * @param string $singularType + * @param int $level + * @return string + */ + protected function _getTypeNameBasedOnNestingLevel($singularType, $level) + { + if($level == 0) { + // This is not an Array anymore, return the xsd simple type + return $singularType; + } else { + $prefix = str_repeat("ArrayOf", $level); + $xsdType = $this->_getStrippedXsdType($singularType); + $arrayType = $prefix.$xsdType; + return $arrayType; + } + } + + /** + * Strip the xsd: from a singularType and Format it nice for ArrayOf naming + * + * @param string $singularType + * @return string + */ + protected function _getStrippedXsdType($singularType) + { + return ucfirst(substr(strtolower($singularType), 4)); + } + + /** + * From a nested defintion with type[], get the singular xsd:type + * + * @throws Zend_Soap_Wsdl_Exception When no xsd:simpletype can be detected. + * @param string $type + * @return string + */ + protected function _getSingularType($type) + { + $singulartype = $this->getContext()->getType(str_replace("[]", "", $type)); + + if(substr($singulartype, 0, 4) != "xsd:") { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception(sprintf( + 'ArrayOfTypeSequence Strategy works only with arrays of simple types like int, string, boolean, not with "%s".'. + 'You may use Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex for more complex types.', $type + )); + } + return $singulartype; + } + + /** + * Return the array nesting level based on the type name + * + * @param string $type + * @return integer + */ + protected function _getNestedCount($type) + { + return substr_count($type, "[]"); + } + + /** + * Append the complex type definition to the WSDL via the context access + * + * @param string $arrayType + * @param string $childTypeName + * @return void + */ + protected function _addElementFromWsdlAndChildTypes($arrayType, $childTypeName) + { + if (!in_array($arrayType, $this->getContext()->getTypes())) { + $dom = $this->getContext()->toDomDocument(); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $arrayType); + + $sequence = $dom->createElement('xsd:sequence'); + + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', 'item'); + $element->setAttribute('type', $childTypeName); + $element->setAttribute('minOccurs', 0); + $element->setAttribute('maxOccurs', 'unbounded'); + $sequence->appendChild($element); + + $complexType->appendChild($sequence); + + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($arrayType); + } + } +} \ No newline at end of file diff --git a/src/Wsdl/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php new file mode 100644 index 00000000..f3714342 --- /dev/null +++ b/src/Wsdl/Strategy/Composite.php @@ -0,0 +1,174 @@ + Strategy pairs. + * + * @var array + */ + protected $_typeMap = array(); + + /** + * Default Strategy of this composite + * + * @var string|Zend_Soap_Wsdl_Strategy_Interface + */ + protected $_defaultStrategy; + + /** + * Context WSDL file that this composite serves + * + * @var Zend_Soap_Wsdl|null + */ + protected $_context; + + /** + * Construct Composite WSDL Strategy. + * + * @throws Zend_Soap_Wsdl_Exception + * @param array $typeMap + * @param string|Zend_Soap_Wsdl_Strategy_Interface $defaultStrategy + */ + public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_Wsdl_Strategy_DefaultComplexType") + { + foreach($typeMap AS $type => $strategy) { + $this->connectTypeToStrategy($type, $strategy); + } + $this->_defaultStrategy = $defaultStrategy; + } + + /** + * Connect a complex type to a given strategy. + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @param string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_Wsdl_Strategy_Composite + */ + public function connectTypeToStrategy($type, $strategy) + { + if(!is_string($type)) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map."); + } + $this->_typeMap[$type] = $strategy; + return $this; + } + + /** + * Return default strategy of this composite + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getDefaultStrategy() + { + $strategy = $this->_defaultStrategy; + if(is_string($strategy) && class_exists($strategy)) { + $strategy = new $strategy; + } + if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception( + "Default Strategy for Complex Types is not a valid strategy object." + ); + } + $this->_defaultStrategy = $strategy; + return $strategy; + } + + /** + * Return specific strategy or the default strategy of this type. + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getStrategyOfType($type) + { + if(isset($this->_typeMap[$type])) { + $strategy = $this->_typeMap[$type]; + + if(is_string($strategy) && class_exists($strategy)) { + $strategy = new $strategy(); + } + + if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception( + "Strategy for Complex Type '".$type."' is not a valid strategy object." + ); + } + $this->_typeMap[$type] = $strategy; + } else { + $strategy = $this->getDefaultStrategy(); + } + return $strategy; + } + + /** + * Method accepts the current WSDL context file. + * + * @param Zend_Soap_Wsdl $context + */ + public function setContext(Zend_Soap_Wsdl $context) + { + $this->_context = $context; + return $this; + } + + /** + * Create a complex type based on a strategy + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return string XSD type + */ + public function addComplexType($type) + { + if(!($this->_context instanceof Zend_Soap_Wsdl) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception( + "Cannot add complex type '".$type."', no context is set for this composite strategy." + ); + } + + $strategy = $this->getStrategyOfType($type); + $strategy->setContext($this->_context); + return $strategy->addComplexType($type); + } +} \ No newline at end of file diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php new file mode 100644 index 00000000..56f5bff9 --- /dev/null +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -0,0 +1,71 @@ +getContext()->toDomDocument(); + $class = new ReflectionClass($type); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $type); + + $all = $dom->createElement('xsd:all'); + + foreach ($class->getProperties() as $property) { + if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) { + + /** + * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType' + * node for describing other classes used as attribute types for current class + */ + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', $property->getName()); + $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); + $all->appendChild($element); + } + } + + $complexType->appendChild($all); + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($type); + + return "tns:$type"; + } +} diff --git a/src/Wsdl/Strategy/Interface.php b/src/Wsdl/Strategy/Interface.php new file mode 100644 index 00000000..d104bbf8 --- /dev/null +++ b/src/Wsdl/Strategy/Interface.php @@ -0,0 +1,40 @@ + $context + */ + public function setContext(Zend_Soap_Wsdl $context); + + /** + * Create a complex type based on a strategy + * + * @param string $type + * @return string XSD type + */ + public function addComplexType($type); +} \ No newline at end of file diff --git a/test/AllTests.php b/test/AllTests.php new file mode 100644 index 00000000..8d54a4a9 --- /dev/null +++ b/test/AllTests.php @@ -0,0 +1,44 @@ +addTestSuite('Zend_Soap_ClientTest'); + $suite->addTestSuite('Zend_Soap_ServerTest'); + $suite->addTestSuite('Zend_Soap_WsdlTest'); + $suite->addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeComplexStrategyTest'); + $suite->addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeSequenceStrategyTest'); + $suite->addTestSuite('Zend_Soap_AutoDiscoverTest'); + $suite->addTestSuite('Zend_Soap_AutoDiscover_OnlineTest'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'Zend_Soap_AllTests::main') { + Zend_Soap_AllTests::main(); +} diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php new file mode 100644 index 00000000..fe05b2b4 --- /dev/null +++ b/test/AutoDiscover/OnlineTest.php @@ -0,0 +1,57 @@ +markTestSkipped('The constant TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI has to be defined to allow the Online test to work.'); + } + $this->baseuri = TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI; + } + + public function testNestedObjectArrayResponse() + { + $wsdl = $this->baseuri."/server1.php?wsdl"; + + $b = new Zend_Soap_Wsdl_ComplexTypeB(); + $b->bar = "test"; + $b->foo = "test"; + + $client = new Zend_Soap_Client($wsdl); + $ret = $client->request($b); + + $this->assertTrue( is_array($ret) ); + $this->assertEquals(1, count($ret) ); + $this->assertTrue( is_array($ret[0]->baz) ); + $this->assertEquals(3, count($ret[0]->baz) ); + + $baz = $ret[0]->baz; + $this->assertEquals("bar", $baz[0]->bar); + $this->assertEquals("bar", $baz[0]->foo); + $this->assertEquals("foo", $baz[1]->bar); + $this->assertEquals("foo", $baz[1]->foo); + $this->assertEquals("test", $baz[2]->bar); + $this->assertEquals("test", $baz[2]->foo); + } + + public function testObjectResponse() + { + $wsdl = $this->baseuri."/server2.php?wsdl"; + + $client = new Zend_Soap_Client($wsdl); + $ret = $client->request("test", "test"); + + $this->assertTrue( ($ret instanceof stdClass) ); + $this->assertEquals("test", $ret->foo); + $this->assertEquals("test", $ret->bar); + } +} \ No newline at end of file diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php new file mode 100644 index 00000000..24d69a07 --- /dev/null +++ b/test/AutoDiscoverTest.php @@ -0,0 +1,781 @@ +[\s]{1,}<)/', '', $xmlstring); + return $xmlstring; + } + + function testSetClass() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->setClass('Zend_Soap_AutoDiscover_Test'); + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_clean()); + + $wsdl = '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . ''; + + $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); + $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/setclass.wsdl'); + } + + function testSetClassWithDifferentStyles() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); + $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); + $server->setClass('Zend_Soap_AutoDiscover_Test'); + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_clean()); + + $wsdl = '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . ''; + + $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); + $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/setclass.wsdl'); + } + + /** + * @group ZF-5072 + */ + function testSetClassWithResponseReturnPartCompabilityMode() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->setClass('Zend_Soap_AutoDiscover_Test'); + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_clean()); + + $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); + $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + + unlink(dirname(__FILE__).'/_files/setclass.wsdl'); + } + + + function testAddFunctionSimple() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_contents()); + $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); + + ob_end_clean(); + $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); + $name = $parts[0]; + + $wsdl = ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''; + $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); + } + + function testAddFunctionSimpleWithDifferentStyle() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); + $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_contents()); + $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); + + ob_end_clean(); + $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); + $name = $parts[0]; + + $wsdl = ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''; + $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); + } + + /** + * @group ZF-5072 + */ + function testAddFunctionSimpleInReturnNameCompabilityMode() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_contents()); + $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); + + ob_end_clean(); + $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); + $name = $parts[0]; + + $wsdl = $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()); + $this->assertContains('', $wsdl); + $this->assertNotContains('assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); + } + + function testAddFunctionMultiple() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc2'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc3'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc4'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc5'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc6'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc7'); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc9'); + + $dom = new DOMDocument(); + ob_start(); + $server->handle(); + $dom->loadXML(ob_get_contents()); + $dom->save(dirname(__FILE__).'/_files/addfunction2.wsdl'); + + ob_end_clean(); + + $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); + $name = $parts[0]; + + $wsdl = ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''; + $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/addfunction2.wsdl'); + } + + /** + * @group ZF-4117 + */ + public function testUseHttpsSchemaIfAccessedThroughHttps() + { + $_SERVER['HTTPS'] = "on"; + $httpsScriptUri = 'https://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertContains($httpsScriptUri, $wsdlOutput); + } + + /** + * @group ZF-4117 + */ + public function testChangeWsdlUriInConstructor() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(true, "http://example.com/service.php"); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertNotContains($scriptUri, $wsdlOutput); + $this->assertContains("http://example.com/service.php", $wsdlOutput); + } + + /** + * @group ZF-4117 + */ + public function testChangeWsdlUriViaSetUri() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(true); + $server->setUri("http://example.com/service.php"); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertNotContains($scriptUri, $wsdlOutput); + $this->assertContains("http://example.com/service.php", $wsdlOutput); + } + + public function testSetNonStringNonZendUriUriThrowsException() + { + $server = new Zend_Soap_AutoDiscover(); + try { + $server->setUri(array("bogus")); + $this->fail(); + } catch(Zend_Soap_AutoDiscover_Exception $e) { + + } + } + + /** + * @group ZF-4117 + */ + public function testChangingWsdlUriAfterGenerationIsPossible() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(true); + $server->setUri("http://example.com/service.php"); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertNotContains($scriptUri, $wsdlOutput); + $this->assertContains("http://example.com/service.php", $wsdlOutput); + + $server->setUri("http://example2.com/service2.php"); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertNotContains($scriptUri, $wsdlOutput); + $this->assertNotContains("http://example.com/service.php", $wsdlOutput); + $this->assertContains("http://example2.com/service2.php", $wsdlOutput); + } + + /** + * @group ZF-4688 + * @group ZF-4125 + * + */ + public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() + { + $scriptUri = 'http://localhost/my_script.php'; + + $server = new Zend_Soap_AutoDiscover(); + $server->setClass('Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertEquals(1, substr_count($wsdlOutput, '')); + $this->assertEquals(1, substr_count($wsdlOutput, '')); + } + + public function testUnusedFunctionsOfAutoDiscoverThrowException() + { + $server = new Zend_Soap_AutoDiscover(); + try { + $server->setPersistence("bogus"); + $this->fail(); + } catch(Zend_Soap_AutoDiscover_Exception $e) { + + } + + try { + $server->fault(); + $this->fail(); + } catch(Zend_Soap_AutoDiscover_Exception $e) { + + } + + try { + $server->loadFunctions("bogus"); + $this->fail(); + } catch(Zend_Soap_AutoDiscover_Exception $e) { + + } + } + + public function testGetFunctions() + { + $server = new Zend_Soap_AutoDiscover(); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server->setClass('Zend_Soap_AutoDiscover_Test'); + + $functions = $server->getFunctions(); + $this->assertEquals( + array('Zend_Soap_AutoDiscover_TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'), + $functions + ); + } + + /** + * @group ZF-4835 + */ + public function testUsingRequestUriWithoutParametersAsDefault() + { + // Apache + $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost'); + $server = new Zend_Soap_AutoDiscover(); + $uri = $server->getUri()->getUri(); + $this->assertNotContains("?wsdl", $uri); + $this->assertEquals("http://localhost/my_script.php", $uri); + + // Apache plus SSL + $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on'); + $server = new Zend_Soap_AutoDiscover(); + $uri = $server->getUri()->getUri(); + $this->assertNotContains("?wsdl", $uri); + $this->assertEquals("https://localhost/my_script.php", $uri); + + // IIS 5 + PHP as FastCGI + $_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); + $server = new Zend_Soap_AutoDiscover(); + $uri = $server->getUri()->getUri(); + $this->assertNotContains("?wsdl", $uri); + $this->assertEquals("http://localhost/my_script.php", $uri); + + // IIS + $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); + $server = new Zend_Soap_AutoDiscover(); + $uri = $server->getUri()->getUri(); + $this->assertNotContains("?wsdl", $uri); + $this->assertEquals("http://localhost/my_script.php", $uri); + } + + /** + * @group ZF-4937 + */ + public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() + { + $server = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); + $server->setClass('Zend_Soap_AutoDiscoverTestClass2'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertEquals(1, + substr_count($wsdlOutput, 'wsdl:arrayType="tns:Zend_Soap_AutoDiscoverTestClass1[]"'), + 'wsdl:arrayType definition of TestClass1 has to occour once.' + ); + $this->assertEquals(1, + substr_count($wsdlOutput, ''), + 'Zend_Soap_AutoDiscoverTestClass1 has to be defined once.' + ); + $this->assertEquals(1, + substr_count($wsdlOutput, ''), + 'ArrayOfZend_Soap_AutoDiscoverTestClass1 should be defined once.' + ); + $this->assertTrue( + substr_count($wsdlOutput, '') >= 1, + 'Zend_Soap_AutoDiscoverTestClass1 appears once or more than once in the message parts section.' + ); + } + + /** + * @group ZF-5330 + */ + public function testDumpOrXmlOfAutoDiscover() + { + $server = new Zend_Soap_AutoDiscover(); + $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + + ob_start(); + $server->handle(); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertEquals( + $this->sanatizeWsdlXmlOutputForOsCompability($wsdlOutput), + $this->sanatizeWsdlXmlOutputForOsCompability($server->toXml()) + ); + + ob_start(); + $server->dump(false); + $wsdlOutput = ob_get_contents(); + ob_end_clean(); + + $this->assertEquals( + $this->sanatizeWsdlXmlOutputForOsCompability($wsdlOutput), + $this->sanatizeWsdlXmlOutputForOsCompability($server->toXml()) + ); + } + + /** + * @group ZF-5330 + */ + public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWsdl() + { + $server = new Zend_Soap_AutoDiscover(); + try { + $server->dump(false); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception); + } + + try { + $server->toXml(); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception); + } + } + + /** + * @group ZF-5604 + */ + public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex() + { + $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); + $autodiscover->setClass('Zend_Soap_AutoDiscover_MyService'); + $wsdl = $autodiscover->toXml(); + + $this->assertEquals(1, substr_count($wsdl, '')); + + $this->assertEquals(0, substr_count($wsdl, 'tns:My_Response[]')); + } + + /** + * @group ZF-5430 + */ + public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence() + { + $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence'); + $autodiscover->setClass('Zend_Soap_AutoDiscover_MyServiceSequence'); + $wsdl = $autodiscover->toXml(); + + $this->assertEquals(1, substr_count($wsdl, '')); + $this->assertEquals(1, substr_count($wsdl, '')); + $this->assertEquals(1, substr_count($wsdl, '')); + + $this->assertEquals(0, substr_count($wsdl, 'tns:string[]')); + } + + /** + * @group ZF-5736 + */ + public function testAmpersandInUrlIsCorrectlyEncoded() + { + $autodiscover = new Zend_Soap_AutoDiscover(); + $autodiscover->setUri("http://example.com/?a=b&b=c"); + + $autodiscover->setClass("Zend_Soap_AutoDiscover_Test"); + $wsdl = $autodiscover->toXml(); + + $this->assertContains("http://example.com/?a=b&b=c", $wsdl); + } +} \ No newline at end of file diff --git a/test/ClientTest.php b/test/ClientTest.php new file mode 100644 index 00000000..b62945bc --- /dev/null +++ b/test/ClientTest.php @@ -0,0 +1,509 @@ +markTestSkipped('SOAP Extension is not loaded'); + } + } + + public function testSetOptions() + { + /************************************************************* + * ------ Test WSDL mode options ----------------------------- + *************************************************************/ + $client = new Zend_Soap_Client(); + + $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); + + $ctx = stream_context_create(); + + $nonWsdlOptions = array('soap_version' => SOAP_1_1, + 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', + 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'use' => SOAP_ENCODED, + 'style' => SOAP_RPC, + + 'login' => 'http_login', + 'password' => 'http_password', + + 'proxy_host' => 'proxy.somehost.com', + 'proxy_port' => 8080, + 'proxy_login' => 'proxy_login', + 'proxy_password' => 'proxy_password', + + 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'passphrase' => 'some pass phrase', + + 'stream_context' => $ctx, + 'cache_wsdl' => 8, + 'features' => 4, + + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); + + $client->setOptions($nonWsdlOptions); + $this->assertTrue($client->getOptions() == $nonWsdlOptions); + + + /************************************************************* + * ------ Test non-WSDL mode options ----------------------------- + *************************************************************/ + $client1 = new Zend_Soap_Client(); + + $this->assertTrue($client1->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); + + $wsdlOptions = array('soap_version' => SOAP_1_1, + 'wsdl' => dirname(__FILE__).'/_files/wsdl_example.wsdl', + 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', + 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'encoding' => 'ISO-8859-1', + + 'login' => 'http_login', + 'password' => 'http_password', + + 'proxy_host' => 'proxy.somehost.com', + 'proxy_port' => 8080, + 'proxy_login' => 'proxy_login', + 'proxy_password' => 'proxy_password', + + 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'passphrase' => 'some pass phrase', + + 'stream_context' => $ctx, + + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); + + $client1->setOptions($wsdlOptions); + $this->assertTrue($client1->getOptions() == $wsdlOptions); + } + + public function testGetOptions() + { + $client = new Zend_Soap_Client(); + + $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); + + $options = array('soap_version' => SOAP_1_1, + 'wsdl' => dirname(__FILE__).'/_files/wsdl_example.wsdl', + + 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', + 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'use' => SOAP_ENCODED, + 'style' => SOAP_RPC, + + 'login' => 'http_login', + 'password' => 'http_password', + + 'proxy_host' => 'proxy.somehost.com', + 'proxy_port' => 8080, + 'proxy_login' => 'proxy_login', + 'proxy_password' => 'proxy_password', + + 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'passphrase' => 'some pass phrase', + + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); + + $client->setOptions($options); + $this->assertTrue($client->getOptions() == $options); + } + + public function testGetFunctions() + { + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server->setClass('Zend_Soap_Client_TestClass'); + + $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + + $this->assertTrue($client->getFunctions() == array('string testFunc1()', + 'string testFunc2(string $who)', + 'string testFunc3(string $who, int $when)', + 'string testFunc4()')); + } + + /** + * @todo Implement testGetTypes(). + */ + public function testGetTypes() + { + // Remove the following line when you implement this test. + $this->markTestIncomplete( + "This test has not been implemented yet." + ); + } + + public function testGetLastRequest() + { + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server->setClass('Zend_Soap_Client_TestClass'); + + $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + + // Perform request + $client->testFunc2('World'); + + $expectedRequest = '' . "\n" + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $this->assertEquals($client->getLastRequest(), $expectedRequest); + } + + public function testGetLastResponse() + { + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server->setClass('Zend_Soap_Client_TestClass'); + + $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + + // Perform request + $client->testFunc2('World'); + + $expectedResponse = '' . "\n" + . '' + . '' + . '' + . 'testFunc2Return' + . 'Hello World!' + . '' + . '' + . '' . "\n"; + + $this->assertEquals($client->getLastResponse(), $expectedResponse); + } + + public function testCallInvoke() + { + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server->setClass('Zend_Soap_Client_TestClass'); + + $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + + $this->assertEquals($client->testFunc2('World'), 'Hello World!'); + } + + public function testSetOptionsWithZendConfig() + { + $ctx = stream_context_create(); + + $nonWsdlOptions = array('soap_version' => SOAP_1_1, + 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', + 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'use' => SOAP_ENCODED, + 'style' => SOAP_RPC, + + 'login' => 'http_login', + 'password' => 'http_password', + + 'proxy_host' => 'proxy.somehost.com', + 'proxy_port' => 8080, + 'proxy_login' => 'proxy_login', + 'proxy_password' => 'proxy_password', + + 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'passphrase' => 'some pass phrase', + + 'stream_context' => $ctx, + + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5 + ); + + $config = new Zend_Config($nonWsdlOptions); + + $client = new Zend_Soap_Client(null, $config); + + $this->assertEquals($nonWsdlOptions, $client->getOptions()); + } + + public function testSetInputHeaders() + { + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server->setClass('Zend_Soap_Client_TestClass'); + + $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + + // Add request header + $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader1', 'SOAP header content 1')); + // Add permanent request header + $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader2', 'SOAP header content 2'), true); + + // Perform request + $client->testFunc2('World'); + + $expectedRequest = '' . "\n" + . '' + . '' + . 'SOAP header content 2' + . 'SOAP header content 1' + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $this->assertEquals($client->getLastRequest(), $expectedRequest); + + + // Add request header + $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader3', 'SOAP header content 3')); + + // Perform request + $client->testFunc2('World'); + + $expectedRequest = '' . "\n" + . '' + . '' + . 'SOAP header content 2' + . 'SOAP header content 3' + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $this->assertEquals($client->getLastRequest(), $expectedRequest); + + + $client->resetSoapInputHeaders(); + + // Add request header + $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader4', 'SOAP header content 4')); + + // Perform request + $client->testFunc2('World'); + + $expectedRequest = '' . "\n" + . '' + . '' + . 'SOAP header content 4' + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $this->assertEquals($client->getLastRequest(), $expectedRequest); + } +} + + +/** Test Class */ +class Zend_Soap_Client_TestClass { + /** + * Test Function 1 + * + * @return string + */ + function testFunc1() + { + return "Hello World"; + } + + /** + * Test Function 2 + * + * @param string $who Some Arg + * @return string + */ + function testFunc2($who) + { + return "Hello $who!"; + } + + /** + * Test Function 3 + * + * @param string $who Some Arg + * @param int $when Some + * @return string + */ + function testFunc3($who, $when) + { + return "Hello $who, How are you $when"; + } + + /** + * Test Function 4 + * + * @return string + */ + static function testFunc4() + { + return "I'm Static!"; + } +} + +/** Test class 2 */ +class Zend_Soap_Client_TestData1 { + /** + * Property1 + * + * @var string + */ + public $property1; + + /** + * Property2 + * + * @var float + */ + public $property2; +} + +/** Test class 2 */ +class Zend_Soap_Client_TestData2 { + /** + * Property1 + * + * @var integer + */ + public $property1; + + /** + * Property1 + * + * @var float + */ + public $property2; +} + + +/* Test Functions */ + +/** + * Test Function + * + * @param string $arg + * @return string + */ +function Zend_Soap_Client_TestFunc1($who) +{ + return "Hello $who"; +} + +/** + * Test Function 2 + */ +function Zend_Soap_Client_TestFunc2() +{ + return "Hello World"; +} + +/** + * Return false + * + * @return bool + */ +function Zend_Soap_Client_TestFunc3() +{ + return false; +} + +/** + * Return true + * + * @return bool + */ +function Zend_Soap_Client_TestFunc4() +{ + return true; +} + +/** + * Return integer + * + * @return int + */ +function Zend_Soap_Client_TestFunc5() +{ + return 123; +} + +/** + * Return string + * + * @return string + */ +function Zend_Soap_Client_TestFunc6() +{ + return "string"; +} + diff --git a/test/ServerTest.php b/test/ServerTest.php new file mode 100644 index 00000000..55ee4bf9 --- /dev/null +++ b/test/ServerTest.php @@ -0,0 +1,1049 @@ +markTestSkipped('SOAP Extension is not loaded'); + } + } + + public function testSetOptions() + { + $server = new Zend_Soap_Server(); + + $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); + + $options = array('soap_version' => SOAP_1_1, + 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1', + 'TestData2' => 'Zend_Soap_Server_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' + ); + $server->setOptions($options); + + $this->assertTrue($server->getOptions() == $options); + } + + public function testSetOptionsViaSecondConstructorArgument() + { + $options = array( + 'soap_version' => SOAP_1_1, + 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'classmap' => array( + 'TestData1' => 'Zend_Soap_Server_TestData1', + 'TestData2' => 'Zend_Soap_Server_TestData2', + ), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + ); + $server = new Zend_Soap_Server(null, $options); + + $this->assertTrue($server->getOptions() == $options); + } + + public function testSetWsdlViaOptionsArrayIsPossible() + { + $server = new Zend_Soap_Server(); + $server->setOptions(array('wsdl' => 'http://www.example.com/test.wsdl')); + + $this->assertEquals('http://www.example.com/test.wsdl', $server->getWsdl()); + } + + public function testGetOptions() + { + $server = new Zend_Soap_Server(); + + $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); + + $options = array('soap_version' => SOAP_1_1, + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' + ); + $server->setOptions($options); + + $this->assertTrue($server->getOptions() == $options); + } + + public function testEncoding() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getEncoding()); + $server->setEncoding('ISO-8859-1'); + $this->assertEquals('ISO-8859-1', $server->getEncoding()); + + try { + $server->setEncoding(array('UTF-8')); + $this->fail('Non-string encoding values should fail'); + } catch (Exception $e) { + // success + } + } + + public function testSoapVersion() + { + $server = new Zend_Soap_Server(); + + $this->assertEquals(SOAP_1_2, $server->getSoapVersion()); + $server->setSoapVersion(SOAP_1_1); + $this->assertEquals(SOAP_1_1, $server->getSoapVersion()); + try { + $server->setSoapVersion('bogus'); + $this->fail('Invalid soap versions should fail'); + } catch (Exception $e) { + // success + } + } + + public function testValidateUrn() + { + $server = new Zend_Soap_Server(); + + try { + $server->validateUrn('bogosity'); + $this->fail('URNs without schemes should fail'); + } catch (Exception $e) { + // success + } + + $this->assertTrue($server->validateUrn('http://framework.zend.com/')); + $this->assertTrue($server->validateUrn('urn:soapHandler/GetOpt')); + } + + public function testSetActor() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getActor()); + $server->setActor('http://framework.zend.com/'); + $this->assertEquals('http://framework.zend.com/', $server->getActor()); + try { + $server->setActor('bogus'); + $this->fail('Invalid actor should fail'); + } catch (Exception $e) { + // success + } + } + + public function testGetActor() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getActor()); + $server->setActor('http://framework.zend.com/'); + $this->assertEquals('http://framework.zend.com/', $server->getActor()); + } + + public function testSetUri() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getUri()); + $server->setUri('http://framework.zend.com/'); + $this->assertEquals('http://framework.zend.com/', $server->getUri()); + try { + $server->setUri('bogus'); + $this->fail('Invalid URI should fail'); + } catch (Exception $e) { + // success + } + } + + public function testGetUri() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getUri()); + $server->setUri('http://framework.zend.com/'); + $this->assertEquals('http://framework.zend.com/', $server->getUri()); + } + + public function testSetClassmap() + { + $server = new Zend_Soap_Server(); + + $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', + 'TestData2' => 'Zend_Soap_Server_TestData2'); + + $this->assertNull($server->getClassmap()); + $server->setClassmap($classmap); + $this->assertTrue($classmap == $server->getClassmap()); + try { + $server->setClassmap('bogus'); + $this->fail('Classmap which is not an array should fail'); + } catch (Exception $e) { + // success + } + try { + $server->setClassmap(array('soapTypeName', 'bogusClassName')); + $this->fail('Invalid class within classmap should fail'); + } catch (Exception $e) { + // success + } + } + + public function testGetClassmap() + { + $server = new Zend_Soap_Server(); + + $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', + 'TestData2' => 'Zend_Soap_Server_TestData2'); + + $this->assertNull($server->getClassmap()); + $server->setClassmap($classmap); + $this->assertTrue($classmap == $server->getClassmap()); + } + + public function testSetWsdl() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getWsdl()); + $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); + $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl()); + try { + $server->setWsdl(dirname(__FILE__).'/_files/bogus.wsdl'); + $this->fail('Invalid WSDL URI or PATH should fail'); + } catch (Exception $e) { + // success + } + } + + public function testGetWsdl() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getWsdl()); + $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); + $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl()); + } + + public function testAddFunction() + { + $server = new Zend_Soap_Server(); + + // Correct function should pass + $server->addFunction('Zend_Soap_Server_TestFunc1'); + + // Array of correct functions should pass + $functions = array('Zend_Soap_Server_TestFunc2', + 'Zend_Soap_Server_TestFunc3', + 'Zend_Soap_Server_TestFunc4'); + $server->addFunction($functions); + + $this->assertEquals( + array_merge(array('Zend_Soap_Server_TestFunc1'), $functions), + $server->getFunctions() + ); + } + + public function testAddBogusFunctionAsInteger() + { + $server = new Zend_Soap_Server(); + try { + $server->addFunction(126); + $this->fail('Invalid value should fail'); + } catch (Zend_Soap_Server_Exception $e) { + // success + } + } + + public function testAddBogusFunctionsAsString() + { + $server = new Zend_Soap_Server(); + + try { + $server->addFunction('bogus_function'); + $this->fail('Invalid function should fail.'); + } catch (Zend_Soap_Server_Exception $e) { + // success + } + } + + public function testAddBogusFunctionsAsArray() + { + $server = new Zend_Soap_Server(); + + try { + $functions = array('Zend_Soap_Server_TestFunc5', + 'bogus_function', + 'Zend_Soap_Server_TestFunc6'); + $server->addFunction($functions); + $this->fail('Invalid function within a set of functions should fail'); + } catch (Zend_Soap_Server_Exception $e) { + // success + } + } + + public function testAddAllFunctionsSoapConstant() + { + $server = new Zend_Soap_Server(); + + // SOAP_FUNCTIONS_ALL as a value should pass + $server->addFunction(SOAP_FUNCTIONS_ALL); + $server->addFunction('substr'); + $this->assertEquals(array(SOAP_FUNCTIONS_ALL), $server->getFunctions()); + } + + public function testSetClass() + { + $server = new Zend_Soap_Server(); + + // Correct class name should pass + try { + $server->setClass('Zend_Soap_Server_TestClass'); + } catch(Exception $e) { + $this->fail("Setting a correct class name should not fail setClass()"); + } + } + + public function testSetClassTwiceThrowsException() + { + $server = new Zend_Soap_Server(); + + // Correct class name should pass + try { + $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('Zend_Soap_Server_TestClass'); + $this->fail(); + } catch(Zend_Soap_Server_Exception $e) { + $this->assertEquals('A class has already been registered with this soap server instance', $e->getMessage()); + } + } + + public function testSetClassWithArguments() + { + $server = new Zend_Soap_Server(); + + // Correct class name should pass + try { + $server->setClass('Zend_Soap_Server_TestClass', 1, 2, 3, 4); + } catch(Exception $e) { + $this->fail("Setting a correct class name should not fail setClass()"); + } + } + + public function testSetBogusClassWithIntegerName() + { + $server = new Zend_Soap_Server(); + + try { + $server->setClass(465); + $this->fail('Non-string value should fail'); + } catch (Exception $e) { + // success + } + } + + public function testSetBogusClassWithUnknownClassName() + { + $server = new Zend_Soap_Server(); + + try { + $server->setClass('Zend_Soap_Server_Test_BogusClass'); + $this->fail('Invalid class should fail'); + } catch (Exception $e) { + // success + } + } + + /** + * @group ZF-4366 + */ + public function testSetObject() + { + $server = new Zend_Soap_Server(); + + try { + $server->setObject(465); + $this->fail('Non-object value should fail'); + } catch (Exception $e) { + // success + } + + try { + $int = 1; + $server->setObject($int); + $this->fail('Invalid argument should fail'); + } catch (Exception $e) { + // success + } + + // Correct class name should pass + $server->setObject(new Zend_Soap_Server_TestClass()); + + try { + $server->setObject(new Zend_Soap_Server_TestClass()); + $this->fail('setClass() should pass only once'); + } catch (Exception $e) { + // success + } + } + + public function testGetFunctions() + { + $server = new Zend_Soap_Server(); + + $server->addFunction('Zend_Soap_Server_TestFunc1'); + + $functions = array('Zend_Soap_Server_TestFunc2', + 'Zend_Soap_Server_TestFunc3', + 'Zend_Soap_Server_TestFunc4'); + $server->addFunction($functions); + + $functions = array('Zend_Soap_Server_TestFunc3', + 'Zend_Soap_Server_TestFunc5', + 'Zend_Soap_Server_TestFunc6'); + $server->addFunction($functions); + + $allAddedFunctions = array( + 'Zend_Soap_Server_TestFunc1', + 'Zend_Soap_Server_TestFunc2', + 'Zend_Soap_Server_TestFunc3', + 'Zend_Soap_Server_TestFunc4', + 'Zend_Soap_Server_TestFunc5', + 'Zend_Soap_Server_TestFunc6' + ); + $this->assertTrue($server->getFunctions() == $allAddedFunctions); + } + + public function testGetFunctionsWithClassAttached() + { + $server = new Zend_Soap_Server(); + $server->setClass('Zend_Soap_Server_TestClass'); + + $this->assertEquals( + array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), + $server->getFunctions() + ); + } + + public function testGetFunctionsWithObjectAttached() + { + $server = new Zend_Soap_Server(); + $server->setObject(new Zend_Soap_Server_TestClass()); + + $this->assertEquals( + array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), + $server->getFunctions() + ); + } + + public function testSetPersistence() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getPersistence()); + $server->setPersistence(SOAP_PERSISTENCE_SESSION); + $this->assertEquals(SOAP_PERSISTENCE_SESSION, $server->getPersistence()); + try { + $server->setSoapVersion('bogus'); + $this->fail('Invalid soap versions should fail'); + } catch (Exception $e) { + // success + } + + $server->setPersistence(SOAP_PERSISTENCE_REQUEST); + $this->assertEquals(SOAP_PERSISTENCE_REQUEST, $server->getPersistence()); + } + + public function testSetUnknownPersistenceStateThrowsException() + { + $server = new Zend_Soap_Server(); + + try { + $server->setPersistence('bogus'); + $this->fail(); + } catch(Zend_Soap_Server_Exception $e) { + + } + } + + public function testGetPersistence() + { + $server = new Zend_Soap_Server(); + + $this->assertNull($server->getPersistence()); + $server->setPersistence(SOAP_PERSISTENCE_SESSION); + $this->assertEquals(SOAP_PERSISTENCE_SESSION, $server->getPersistence()); + } + + public function testGetLastRequest() + { + $server = new Zend_Soap_Server(); + $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); + $server->setReturnResponse(true); + + $server->setClass('Zend_Soap_Server_TestClass'); + + $request = + '' . "\n" + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $response = $server->handle($request); + + $this->assertEquals($request, $server->getLastRequest()); + } + + public function testSetReturnResponse() + { + $server = new Zend_Soap_Server(); + + $this->assertFalse($server->getReturnResponse()); + + $server->setReturnResponse(true); + $this->assertTrue($server->getReturnResponse()); + + $server->setReturnResponse(false); + $this->assertFalse($server->getReturnResponse()); + } + + public function testGetReturnResponse() + { + $server = new Zend_Soap_Server(); + + $this->assertFalse($server->getReturnResponse()); + + $server->setReturnResponse(true); + $this->assertTrue($server->getReturnResponse()); + } + + public function testGetLastResponse() + { + $server = new Zend_Soap_Server(); + $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); + $server->setReturnResponse(true); + + $server->setClass('Zend_Soap_Server_TestClass'); + + $request = + '' . "\n" + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $expectedResponse = + '' . "\n" + . '' + . '' + . '' + . 'Hello World!' + . '' + . '' + . '' . "\n"; + + $server->handle($request); + + $this->assertEquals($expectedResponse, $server->getLastResponse()); + } + + public function testHandle() + { + $server = new Zend_Soap_Server(); + $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); + + $server->setClass('Zend_Soap_Server_TestClass'); + + $localClient = new Zend_Soap_Server_TestLocalSoapClient($server, + null, + array('location'=>'test://', + 'uri'=>'http://framework.zend.com')); + + // Local SOAP client call automatically invokes handle method of the provided SOAP server + $this->assertEquals('Hello World!', $localClient->testFunc2('World')); + + + $request = + '' . "\n" + . '' + . '' + . '' + . 'World' + . '' + . '' + . '' . "\n"; + + $expectedResponse = + '' . "\n" + . '' + . '' + . '' + . 'Hello World!' + . '' + . '' + . '' . "\n"; + + $server1 = new Zend_Soap_Server(); + $server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); + + $server1->setClass('Zend_Soap_Server_TestClass'); + $server1->setReturnResponse(true); + + $this->assertEquals($expectedResponse, $server1->handle($request)); + } + + /** + * @todo Implement testRegisterFaultException(). + */ + public function testRegisterFaultException() + { + $server = new Zend_Soap_Server(); + + $server->registerFaultException("Zend_Soap_Server_Exception"); + $server->registerFaultException(array("OutOfBoundsException", "BogusException")); + + $this->assertEquals(array( + 'Zend_Soap_Server_Exception', + 'OutOfBoundsException', + 'BogusException', + ), $server->getFaultExceptions()); + } + + /** + * @todo Implement testDeregisterFaultException(). + */ + public function testDeregisterFaultException() + { + $server = new Zend_Soap_Server(); + + $server->registerFaultException(array("OutOfBoundsException", "BogusException")); + $ret = $server->deregisterFaultException("BogusException"); + $this->assertTrue($ret); + + $this->assertEquals(array( + 'OutOfBoundsException', + ), $server->getFaultExceptions()); + + $ret = $server->deregisterFaultException("NonRegisteredException"); + $this->assertFalse($ret); + } + + /** + * @todo Implement testGetFaultExceptions(). + */ + public function testGetFaultExceptions() + { + $server = new Zend_Soap_Server(); + + $this->assertEquals(array(), $server->getFaultExceptions()); + $server->registerFaultException("Exception"); + $this->assertEquals(array("Exception"), $server->getFaultExceptions()); + } + + public function testFaultWithTextMessage() + { + $server = new Zend_Soap_Server(); + $fault = $server->fault("Faultmessage!"); + + $this->assertTrue($fault instanceof SOAPFault); + $this->assertContains("Faultmessage!", $fault->getMessage()); + } + + public function testFaultWithUnregisteredException() + { + $server = new Zend_Soap_Server(); + $fault = $server->fault(new Exception("MyException")); + + $this->assertTrue($fault instanceof SOAPFault); + $this->assertContains("Unknown error", $fault->getMessage()); + $this->assertNotContains("MyException", $fault->getMessage()); + } + + public function testFaultWithRegisteredException() + { + $server = new Zend_Soap_Server(); + $server->registerFaultException("Exception"); + $fault = $server->fault(new Exception("MyException")); + + $this->assertTrue($fault instanceof SOAPFault); + $this->assertNotContains("Unknown error", $fault->getMessage()); + $this->assertContains("MyException", $fault->getMessage()); + } + + public function testFautlWithBogusInput() + { + $server = new Zend_Soap_Server(); + $fault = $server->fault(array("Here", "There", "Bogus")); + + $this->assertContains("Unknown error", $fault->getMessage()); + } + + /** + * @group ZF-3958 + */ + public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault() + { + $server = new Zend_Soap_Server(); + $fault = $server->fault("Faultmessage!", 5000); + + $this->assertTrue($fault instanceof SOAPFault); + } + + /** + * @todo Implement testHandlePhpErrors(). + */ + public function testHandlePhpErrors() + { + $server = new Zend_Soap_Server(); + + // Remove the following line when you implement this test. + $this->markTestIncomplete( + "This test has not been implemented yet." + ); + } + + public function testLoadFunctionsIsNotImplemented() + { + $server = new Zend_Soap_Server(); + + try { + $server->loadFunctions("bogus"); + $this->fail(); + } catch(Zend_Soap_Server_Exception $e) { + + } + } + + public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHandleMode() + { + $server = new Zend_Soap_Server(); + $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); + $server->setReturnResponse(true); + + // Requesting Method with enforced parameter without it. + $request = + '' . "\n" + . '' + . '' + . '' + . '' + . '' . "\n"; + + $server->setClass('Zend_Soap_Server_TestClass'); + $response = $server->handle($request); + + $this->assertContains( + 'ReceiverTest Message', + $response + ); + } + + /** + * @group ZF-5597 + */ + public function testServerAcceptsZendConfigObject() + { + $options = array('soap_version' => SOAP_1_1, + 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1', + 'TestData2' => 'Zend_Soap_Server_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' + ); + $config = new Zend_Config($options); + + $server = new Zend_Soap_Server(); + $server->setOptions($config); + $this->assertEquals($options, $server->getOptions()); + } + + /** + * @group ZF-5300 + */ + public function testSetAndGetFeatures() + { + $server = new Zend_Soap_Server(); + $this->assertNull($server->getSoapFeatures()); + $server->setSoapFeatures(100); + $this->assertEquals(100, $server->getSoapFeatures()); + $options = $server->getOptions(); + $this->assertTrue(isset($options['features'])); + $this->assertEquals(100, $options['features']); + } + + /** + * @group ZF-5300 + */ + public function testSetAndGetWsdlCache() + { + $server = new Zend_Soap_Server(); + $this->assertNull($server->getWsdlCache()); + $server->setWsdlCache(100); + $this->assertEquals(100, $server->getWsdlCache()); + $options = $server->getOptions(); + $this->assertTrue(isset($options['cache_wsdl'])); + $this->assertEquals(100, $options['cache_wsdl']); + } +} + + +if (extension_loaded('soap')) { + +/** Local SOAP client */ +class Zend_Soap_Server_TestLocalSoapClient extends SoapClient { + /** + * Server object + * + * @var Zend_Soap_Server + */ + public $server; + + /** + * Local client constructor + * + * @param Zend_Soap_Server $server + * @param string $wsdl + * @param array $options + */ + function __construct(Zend_Soap_Server $server, $wsdl, $options) { + $this->server = $server; + parent::__construct($wsdl, $options); + } + + function __doRequest($request, $location, $action, $version) { + ob_start(); + $this->server->handle($request); + $response = ob_get_contents(); + ob_end_clean(); + + return $response; + } +} + +} + + +/** Test Class */ +class Zend_Soap_Server_TestClass { + /** + * Test Function 1 + * + * @return string + */ + function testFunc1() + { + return "Hello World"; + } + + /** + * Test Function 2 + * + * @param string $who Some Arg + * @return string + */ + function testFunc2($who) + { + return "Hello $who!"; + } + + /** + * Test Function 3 + * + * @param string $who Some Arg + * @param int $when Some + * @return string + */ + function testFunc3($who, $when) + { + return "Hello $who, How are you $when"; + } + + /** + * Test Function 4 + * + * @return string + */ + static function testFunc4() + { + return "I'm Static!"; + } + + /** + * Test Function 5 raises a user error + * + * @return void + */ + function testFunc5() + { + trigger_error("Test Message", E_USER_ERROR); + } +} + + +/** Test class 2 */ +class Zend_Soap_Server_TestData1 { + /** + * Property1 + * + * @var string + */ + public $property1; + + /** + * Property2 + * + * @var float + */ + public $property2; +} + +/** Test class 2 */ +class Zend_Soap_Server_TestData2 { + /** + * Property1 + * + * @var integer + */ + public $property1; + + /** + * Property1 + * + * @var float + */ + public $property2; +} + + +/* Test Functions */ + +/** + * Test Function + * + * @param string $arg + * @return string + */ +function Zend_Soap_Server_TestFunc1($who) +{ + return "Hello $who"; +} + +/** + * Test Function 2 + */ +function Zend_Soap_Server_TestFunc2() +{ + return "Hello World"; +} + +/** + * Return false + * + * @return bool + */ +function Zend_Soap_Server_TestFunc3() +{ + return false; +} + +/** + * Return true + * + * @return bool + */ +function Zend_Soap_Server_TestFunc4() +{ + return true; +} + +/** + * Return integer + * + * @return int + */ +function Zend_Soap_Server_TestFunc5() +{ + return 123; +} + +/** + * Return string + * + * @return string + */ +function Zend_Soap_Server_TestFunc6() +{ + return "string"; +} \ No newline at end of file diff --git a/test/Wsdl/AllTests.php b/test/Wsdl/AllTests.php new file mode 100644 index 00000000..209cbe96 --- /dev/null +++ b/test/Wsdl/AllTests.php @@ -0,0 +1,21 @@ +addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeComplexStrategyTest'); + $suite->addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeSequenceStrategyTest'); + $suite->addTestSuite('Zend_Soap_Wsdl_DefaultComplexTypeTest'); + + return $suite; + } +} \ No newline at end of file diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php new file mode 100644 index 00000000..0b800738 --- /dev/null +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -0,0 +1,224 @@ +strategy = new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex(); + $this->wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $this->strategy); + } + + public function testNestingObjectsDeepMakesNoSenseThrowingException() + { + try { + $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[][]'); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testAddComplexTypeOfNonExistingClassThrowsException() + { + try { + $this->wsdl->addComplexType('Zend_Soap_Wsdl_UnknownClass[]'); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + /** + * @group ZF-5046 + */ + public function testArrayOfSimpleObject() + { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[]'); + $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexTest", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + } + + public function testThatOverridingStrategyIsReset() + { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[]'); + $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexTest", $return); + #$this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplexStrategy); + + $wsdl = $this->wsdl->toXML(); + } + + /** + * @group ZF-5046 + */ + public function testArrayOfComplexObjects() + { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectStructure[]'); + $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexObjectStructure", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + } + + public function testArrayOfObjectWithObject() + { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); + $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexObjectWithObjectStructure", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + } + + /** + * @group ZF-4937 + */ + public function testAddingTypesMultipleTimesIsSavedOnlyOnce() + { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); + + $wsdl = $this->wsdl->toXML(); + + $this->assertEquals(1, + substr_count($wsdl, 'wsdl:arrayType="tns:Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]"') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + } + + /** + * @group ZF-4937 + */ + public function testAddingSingularThenArrayTypeIsRecognizedCorretly() + { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure'); + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); + + $wsdl = $this->wsdl->toXML(); + + $this->assertEquals(1, + substr_count($wsdl, 'wsdl:arrayType="tns:Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]"') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + } + + /** + * @group ZF-5149 + */ + public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowingException() + { + try { + $return = $this->wsdl->addComplexType("Zend_Soap_Wsdl_ComplexTypeA"); + $wsdl = $this->wsdl->toXml(); + } catch(Exception $e) { + $this->fail("Adding object with nested structure should not throw exception."); + } + } + + /** + * @group ZF-5149 + */ + public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllTypesRecursivly() + { + $return = $this->wsdl->addComplexType("Zend_Soap_Wsdl_ComplexTypeA"); + $wsdl = $this->wsdl->toXml(); + + $this->assertEquals(1, + substr_count($wsdl, ''), + 'No definition of complex type A found.' + ); + $this->assertEquals(1, + substr_count($wsdl, ''), + 'No definition of complex type B array found.' + ); + $this->assertEquals(1, + substr_count($wsdl, 'wsdl:arrayType="tns:Zend_Soap_Wsdl_ComplexTypeB[]"'), + 'No usage of Complex Type B array found.' + ); + } + + /** + * @group ZF-5754 + */ + public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() + { + try { + $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); + $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itsself.", $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php new file mode 100644 index 00000000..ef0fd204 --- /dev/null +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -0,0 +1,151 @@ +strategy = new Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence(); + $this->wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $this->strategy); + } + + public function testFunctionReturningSimpleArrayOfInts() + { + $this->wsdl->addComplexType('int[]'); + + $this->assertContains( + ''. + ''. + '', + $this->wsdl->toXML() + ); + } + + public function testFunctionReturningSimpleArrayOfString() + { + $this->wsdl->addComplexType('string[]'); + + $this->assertContains( + ''. + ''. + '', + $this->wsdl->toXML() + ); + } + + public function testFunctionReturningNestedArrayOfString() + { + $return = $this->wsdl->addComplexType('string[][]'); + $this->assertEquals("tns:ArrayOfArrayOfString", $return); + + $wsdl = $this->wsdl->toXML(); + + // Check for ArrayOfArrayOfString + $this->assertContains( + '', + $wsdl + ); + // Check for ArrayOfString + $this->assertContains( + '', + $wsdl + ); + } + + public function testFunctionReturningMultipleNestedArrayOfType() + { + $return = $this->wsdl->addComplexType('string[][][]'); + $this->assertEquals("tns:ArrayOfArrayOfArrayOfString", $return); + + $wsdl = $this->wsdl->toXML(); + + // Check for ArrayOfArrayOfArrayOfString + $this->assertContains( + '', + $wsdl + ); + // Check for ArrayOfArrayOfString + $this->assertContains( + '', + $wsdl + ); + // Check for ArrayOfString + $this->assertContains( + '', + $wsdl + ); + } + + public function testSpecifyingNonSimpleArrayTypeThrowsException() + { + try { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest[]'); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testStrategyCannotHandleReturnOfObjectsThrowingException() + { + try { + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest'); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testAddComplexTypeOfNonExistingClassThrowsException() + { + try { + $this->wsdl->addComplexType('Zend_Soap_Wsdl_UnknownClass[]'); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } +} + +class Zend_Soap_Wsdl_SequenceTest +{ + /** + * @var int + */ + public $var = 5; +} \ No newline at end of file diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php new file mode 100644 index 00000000..9564bc4b --- /dev/null +++ b/test/Wsdl/CompositeStrategyTest.php @@ -0,0 +1,139 @@ +connectTypeToStrategy("Book", "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex"); + + $bookStrategy = $strategy->getStrategyOfType("Book"); + $cookieStrategy = $strategy->getStrategyOfType("Cookie"); + + $this->assertTrue( $bookStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex ); + $this->assertTrue( $cookieStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence ); + } + + public function testConstructorTypeMapSyntax() + { + $typeMap = array("Book" => "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex"); + + $strategy = new Zend_Soap_Wsdl_Strategy_Composite($typeMap, "Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence"); + + $bookStrategy = $strategy->getStrategyOfType("Book"); + $cookieStrategy = $strategy->getStrategyOfType("Cookie"); + + $this->assertTrue( $bookStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex ); + $this->assertTrue( $cookieStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence ); + } + + public function testCompositeThrowsExceptionOnInvalidType() + { + $strategy = new Zend_Soap_Wsdl_Strategy_Composite(); + try { + $strategy->connectTypeToStrategy(array(), "strategy"); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); + } + } + + public function testCompositeThrowsExceptionOnInvalidStrategy() + { + $strategy = new Zend_Soap_Wsdl_Strategy_Composite(array(), "invalid"); + $strategy->connectTypeToStrategy("Book", "strategy"); + + try { + $book = $strategy->getStrategyOfType("Book"); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); + } + + try { + $book = $strategy->getStrategyOfType("Anything"); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); + } + } + + public function testCompositeDelegatesAddingComplexTypesToSubStrategies() + { + $strategy = new Zend_Soap_Wsdl_Strategy_Composite(array(), "Zend_Soap_Wsdl_Strategy_AnyType"); + $strategy->connectTypeToStrategy("Zend_Soap_Wsdl_Book", "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex"); + $strategy->connectTypeToStrategy("Zend_Soap_Wsdl_Cookie", "Zend_Soap_Wsdl_Strategy_DefaultComplexType"); + + $wsdl = new Zend_Soap_Wsdl("SomeService", "http://example.com"); + $strategy->setContext($wsdl); + + $this->assertEquals("tns:Zend_Soap_Wsdl_Book", $strategy->addComplexType("Zend_Soap_Wsdl_Book")); + $this->assertEquals("tns:Zend_Soap_Wsdl_Cookie", $strategy->addComplexType("Zend_Soap_Wsdl_Cookie")); + $this->assertEquals("xsd:anyType", $strategy->addComplexType("Zend_Soap_Wsdl_Anything")); + } + + public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrowsException() + { + $strategy = new Zend_Soap_Wsdl_Strategy_Composite(); + try { + $strategy->addComplexType("Test"); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); + } + } +} + +class Zend_Soap_Wsdl_Book +{ + /** + * @var int + */ + public $somevar; +} +class Zend_Soap_Wsdl_Cookie +{ + /** + * @var int + */ + public $othervar; +} +class Zend_Soap_Wsdl_Anything +{ +} \ No newline at end of file diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php new file mode 100644 index 00000000..dad4cb27 --- /dev/null +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -0,0 +1,60 @@ +strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType(); + $this->wsdl = new Zend_Soap_Wsdl("TestService", "http://framework.zend.com/soap/unittests"); + $this->wsdl->setComplexTypeStrategy($this->strategy); + $this->strategy->setContext($this->wsdl); + } + + /** + * @group ZF-5944 + */ + public function testOnlyPublicPropertiesAreDiscoveredByStrategy() + { + $this->strategy->addComplexType("Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected"); + + $xml = $this->wsdl->toXML(); + $this->assertNotContains( Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected::PROTECTED_VAR_NAME, $xml); + $this->assertNotContains( Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected::PRIVATE_VAR_NAME, $xml); + } +} + +class Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected +{ + const PROTECTED_VAR_NAME = 'bar'; + const PRIVATE_VAR_NAME = 'baz'; + + /** + * @var string + */ + public $foo; + + /** + * @var string + */ + protected $bar; + + /** + * @var string + */ + private $baz; +} \ No newline at end of file diff --git a/test/Wsdl/ElementTest.php b/test/Wsdl/ElementTest.php new file mode 100644 index 00000000..839802c4 --- /dev/null +++ b/test/Wsdl/ElementTest.php @@ -0,0 +1,217 @@ +assertEquals("name1", $binding->getName()); + $this->assertEquals("port1", $binding->portName); + $this->assertEquals($operations, $binding->operations); + $this->assertEquals("test", $binding->getDocumentation()); + + try { + $binding = new Zend_Soap_Wsdl_Element_Binding(array(), "portName", $operations, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testTypeElementApi() + { + $types = new Zend_Soap_Wsdl_Element_Collection("test"); + $type = new Zend_Soap_Wsdl_Element_Type("name1", $types, "test"); + + $this->assertEquals("name1", $type->getName()); + $this->assertEquals($types, $type->types); + $this->assertEquals("test", $type->getDocumentation()); + + try { + $type = new Zend_Soap_Wsdl_Element_Type(array(), $types, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testMessageElementApi() + { + $parts = new Zend_Soap_Wsdl_Element_Collection("test"); + $message = new Zend_Soap_Wsdl_Element_Message("name1", $parts, "test"); + + $this->assertEquals("name1", $message->getName()); + $this->assertEquals($parts, $message->parts); + $this->assertEquals("test", $message->getDocumentation()); + + try { + $message = new Zend_Soap_Wsdl_Element_Message(array(), $parts, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testPortElementApi() + { + $operations = new Zend_Soap_Wsdl_Element_Collection("test"); + $port = new Zend_Soap_Wsdl_Element_Port("name1", $operations, "test"); + + $this->assertEquals("name1", $port->getName()); + $this->assertEquals($operations, $port->operations); + $this->assertEquals("test", $port->getDocumentation()); + + try { + $port = new Zend_Soap_Wsdl_Element_Port(array(), $operations, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testOperationElementApi() + { + $collection = new Zend_Soap_Wsdl_Element_Collection("test"); + $input = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); + $output = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); + + $operation = new Zend_Soap_Wsdl_Element_Operation("name1", $input, $output, "test"); + + $this->assertEquals("name1", $operation->getName()); + $this->assertEquals($input, $operation->inputMessage); + $this->assertEquals($output, $operation->outputMessage); + $this->assertEquals("test", $operation->getDocumentation()); + + try { + $operation = new Zend_Soap_Wsdl_Element_Operation(array(), $input, $output, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testServiceElementApi() + { + $collection = new Zend_Soap_Wsdl_Element_Collection("test"); + $port = new Zend_Soap_Wsdl_Element_Port("name", $collection, "test"); + $binding = new Zend_Soap_Wsdl_Element_Binding("name", "port", $collection, "test"); + + $service = new Zend_Soap_Wsdl_Element_Service("service", "address", $port, $binding, "test"); + + $this->assertEquals("service", $service->getName()); + $this->assertEquals("address", $service->soapAddress); + $this->assertEquals($port, $service->port); + $this->assertEquals($binding, $service->binding); + $this->assertEquals("test", $service->getDocumentation()); + + try { + $service = new Zend_Soap_Wsdl_Element_Service(array(), "address", $port, $binding, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + + try { + $service = new Zend_Soap_Wsdl_Element_Service("name", array(), $port, $binding, "test"); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testCollectionElementApiConstruct() + { + $collection = new Zend_Soap_Wsdl_Element_Collection("Operation"); + + $this->assertTrue($collection instanceof Countable); + $this->assertTrue($collection instanceof Iterator); + + try { + $type = new Zend_Soap_Wsdl_Element_Type("type", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); + $collection->addElement($type); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + + try { + $collection = new Zend_Soap_Wsdl_Element_Collection(false); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testCollectionElementApiType() + { + $collection = new Zend_Soap_Wsdl_Element_Collection("Operation"); + $this->assertEquals("Zend_Soap_Wsdl_Element_Operation", $collection->getType()); + + $collection = new Zend_Soap_Wsdl_Element_Collection("Type"); + $this->assertEquals("Zend_Soap_Wsdl_Element_Type", $collection->getType()); + + $collection = new Zend_Soap_Wsdl_Element_Collection("Binding"); + $this->assertEquals("Zend_Soap_Wsdl_Element_Binding", $collection->getType()); + + $collection = new Zend_Soap_Wsdl_Element_Collection("Service"); + $this->assertEquals("Zend_Soap_Wsdl_Element_Service", $collection->getType()); + + $collection = new Zend_Soap_Wsdl_Element_Collection("Port"); + $this->assertEquals("Zend_Soap_Wsdl_Element_Port", $collection->getType()); + + $collection = new Zend_Soap_Wsdl_Element_Collection("Message"); + $this->assertEquals("Zend_Soap_Wsdl_Element_Message", $collection->getType()); + } + + public function testCollectionElementApiElementAccess() + { + $collection = new Zend_Soap_Wsdl_Element_Collection("Message"); + $message1 = new Zend_Soap_Wsdl_Element_Message("message1", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); + $message2 = new Zend_Soap_Wsdl_Element_Message("message2", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); + $messageDuplicate = new Zend_Soap_Wsdl_Element_Message("message2", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); + + $collection->addElement($message1); + $this->assertEquals(array("message1"), $collection->getElementNames()); + $this->assertEquals($message1, $collection->getElement("message1")); + $this->assertEquals(1, count($collection)); + + $collection->addElement($message2); + $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); + $this->assertEquals($message2, $collection->getElement("message2")); + $this->assertEquals(2, count($collection)); + + try { + // Adding duplicate message leads to exception + $collection->addElement($messageDuplicate); + $this->fail("Adding a duplicate named element to a collection should throw an exception."); + } catch(Zend_Soap_Wsdl_Exception $e) { + $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); + $this->assertEquals($message2, $collection->getElement("message2")); + $this->assertEquals(2, count($collection)); + } + + try { + // Accessing unkown message leads to exception + $collection->getElement("messageUnknown"); + $this->fail("Accessing unknown element should throw an exception."); + } catch(Zend_Soap_Wsdl_Exception $e) { + $this->assertEquals(2, count($collection)); + } + + foreach($collection AS $name => $message) { + $this->assertTrue($message instanceof Zend_Soap_Wsdl_Element_Message); + $this->assertTrue( in_array($name, $collection->getElementNames()) ); + } + } +} \ No newline at end of file diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php new file mode 100644 index 00000000..e24511ee --- /dev/null +++ b/test/Wsdl/ParserTest.php @@ -0,0 +1,159 @@ +loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl")); + return $dom; + } + + public function testFactoryWithDomDocument() + { + $dom = $this->getWsdlExampleDom(); + $parser = Zend_Soap_Wsdl_Parser::factory($dom); + $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + } + + public function testFactoryWithString() + { + $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); + $parser = Zend_Soap_Wsdl_Parser::factory($xmlString); + $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + } + + public function testFactoryWithSimpleXml() + { + $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); + $simpleXml = simplexml_load_string($xmlString); + $parser = Zend_Soap_Wsdl_Parser::factory($simpleXml); + $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + } + + public function testFactoryWithZendSoapWsdl() + { + $wsdl = new Zend_Soap_Wsdl("name", "http://example.com"); + $parser = Zend_Soap_Wsdl_Parser::factory($wsdl); + $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + } + + public function testFactoryWithInvalidParser() + { + $wsdl = new Zend_Soap_Wsdl("name", "http://example.com"); + try { + $parser = Zend_Soap_Wsdl_Parser::factory($wsdl, "stdClass"); + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Parser_Exception); + } + } + + public function testFactoryWithInvalidData() + { + try { + $parser = Zend_Soap_Wsdl_Parser::factory(null); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + public function testParserApiInterface() + { + // Constructor expects DOMDocument instance + $dom = $this->getWsdlExampleDom(); + $parser = new Zend_Soap_Wsdl_Parser($dom); + + // SetWsdl is a fluent function + $this->assertTrue( ($parser->setDomDocumentContainingWsdl($dom)) instanceof Zend_Soap_Wsdl_Parser ); + + // Parse returns Result + $result = $parser->parse(); + $this->assertTrue($result instanceof Zend_Soap_Wsdl_Parser_Result); + } + + public function testParserResultApiInterface() + { + $result = new Zend_Soap_Wsdl_Parser_Result( + "name", + Zend_Soap_Wsdl_Parser::WSDL_11, + new Zend_Soap_Wsdl_Element_Collection("Operation"), + new Zend_Soap_Wsdl_Element_Collection("Port"), + new Zend_Soap_Wsdl_Element_Collection("Binding"), + new Zend_Soap_Wsdl_Element_Collection("Service"), + new Zend_Soap_Wsdl_Element_Collection("Type"), + array("docs") + ); + + $this->assertEquals("name", $result->getName()); + $this->assertEquals("Zend_Soap_Wsdl_Element_Operation", $result->operations->getType()); + $this->assertEquals("Zend_Soap_Wsdl_Element_Port", $result->ports->getType()); + $this->assertEquals("Zend_Soap_Wsdl_Element_Binding", $result->bindings->getType()); + $this->assertEquals("Zend_Soap_Wsdl_Element_Service", $result->services->getType()); + $this->assertEquals("Zend_Soap_Wsdl_Element_Type", $result->types->getType()); + $this->assertEquals(array("docs"), $result->documentation); + + try { + $key = $result->invalidKeyThrowsException; + $this->fail(); + } catch(Exception $e) { + $this->assertTrue($e instanceof Zend_Soap_Wsdl_Parser_Exception); + } + } + + public function testParseExampleWsdlAndCountResultElements() + { + // Constructor expects DOMDocument instance + $dom = $this->getWsdlExampleDom(); + $parser = new Zend_Soap_Wsdl_Parser($dom); + + $result = $parser->parse(); + + $this->assertEquals("Zend_Soap_Server_TestClass", $result->getName()); + $this->assertEquals(Zend_Soap_Wsdl_Parser::WSDL_11, $result->getVersion()); + $this->assertEquals(4, count($result->operations), "Number of operations does not match."); + $this->assertEquals(1, count($result->bindings), "Number of bindings does not match."); + $this->assertEquals(1, count($result->ports), "Number of ports does not match."); + $this->assertEquals(1, count($result->services), "Number of services does not match."); + $this->assertEquals(0, count($result->types), "Number of types does not match."); + $this->assertEquals(4, count($result->bindings->current()->operations), "Number of operations in the bindings collection does not match."); + $this->assertEquals(4, count($result->ports->current()->operations), "Number of operations in the ports collection does not match."); + } + + public function testParseExampleWsdlAndCheckMatchingNames() + { + // Constructor expects DOMDocument instance + $dom = $this->getWsdlExampleDom(); + $parser = new Zend_Soap_Wsdl_Parser($dom); + + $result = $parser->parse(); + + foreach($result->operations AS $operation) { + $this->assertContains($operation->getName(), array("testFunc1", "testFunc2", "testFunc3", "testFunc4")); + } + foreach($result->bindings AS $binding) { + $this->assertEquals("Zend_Soap_Server_TestClassBinding", $binding->getName()); + } + foreach($result->ports AS $port) { + $this->assertEquals("Zend_Soap_Server_TestClassPort", $port->getName()); + } + foreach($result->services AS $service) { + $this->assertEquals("Zend_Soap_Server_TestClassService", $service->getName()); + } + } + + public function testParseExampleWsdlWithDocumentationBlocks() + { + $dom = new DOMDocument(); + $dom->loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_documentation.wsdl")); + + $parser = new Zend_Soap_Wsdl_Parser($dom); + $result = $parser->parse(); + } +} \ No newline at end of file diff --git a/test/WsdlTest.php b/test/WsdlTest.php new file mode 100644 index 00000000..7d4cb8d6 --- /dev/null +++ b/test/WsdlTest.php @@ -0,0 +1,647 @@ +[\s]{1,}<)/', '', $xmlstring); + return $xmlstring; + } + + function testConstructor() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' ); + } + + function testSetUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl->setUri('http://localhost/MyNewService.php'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' ); + } + + function testAddMessage() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $messageParts = array(); + $messageParts['parameter1'] = $wsdl->getType('int'); + $messageParts['parameter2'] = $wsdl->getType('string'); + $messageParts['parameter3'] = $wsdl->getType('mixed'); + + $wsdl->addMessage('myMessage', $messageParts); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + function testAddPortType() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addPortType('myPortType'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' ); + } + + function testAddPortOperation() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $portType = $wsdl->addPortType('myPortType'); + + $wsdl->addPortOperation($portType, 'operation1'); + $wsdl->addPortOperation($portType, 'operation2', 'tns:operation2Request', 'tns:operation2Response'); + $wsdl->addPortOperation($portType, 'operation3', 'tns:operation3Request', 'tns:operation3Response', 'tns:operation3Fault'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + function testAddBinding() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addPortType('myPortType'); + $wsdl->addBinding('MyServiceBinding', 'myPortType'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' ); + } + + function testAddBindingOperation() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addPortType('myPortType'); + $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); + + $wsdl->addBindingOperation($binding, 'operation1'); + $wsdl->addBindingOperation($binding, + 'operation2', + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") + ); + $wsdl->addBindingOperation($binding, + 'operation3', + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") + ); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + function testAddSoapBinding() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addPortType('myPortType'); + $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); + + $wsdl->addSoapBinding($binding); + + $wsdl->addBindingOperation($binding, 'operation1'); + $wsdl->addBindingOperation($binding, + 'operation2', + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") + ); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + + $wsdl1 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl1->addPortType('myPortType'); + $binding = $wsdl1->addBinding('MyServiceBinding', 'myPortType'); + + $wsdl1->addSoapBinding($binding, 'rpc'); + + $wsdl1->addBindingOperation($binding, 'operation1'); + $wsdl1->addBindingOperation($binding, + 'operation2', + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") + ); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl1->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + + function testAddSoapOperation() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addPortType('myPortType'); + $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); + + $wsdl->addSoapOperation($binding, 'http://localhost/MyService.php#myOperation'); + + $wsdl->addBindingOperation($binding, 'operation1'); + $wsdl->addBindingOperation($binding, + 'operation2', + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), + array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") + ); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + function testAddService() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addPortType('myPortType'); + $wsdl->addBinding('MyServiceBinding', 'myPortType'); + + $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + function testAddDocumentation() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $portType = $wsdl->addPortType('myPortType'); + + $wsdl->addDocumentation($portType, 'This is a description for Port Type node.'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . 'This is a description for Port Type node.' + . '' + . '' ); + } + + function testToXml() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' ); + } + + function testToDomDocument() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $dom = $wsdl->toDomDocument(); + + $this->assertTrue($dom instanceOf DOMDocument); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), + '' . + '' ); + } + + function testDump() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + ob_start(); + $wsdl->dump(); + $wsdlDump = ob_get_contents(); + ob_end_clean(); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdlDump), + '' . + '' ); + + $wsdl->dump(dirname(__FILE__) . '/_files/dumped.wsdl'); + $dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($dumpedContent), + '' . + '' ); + + unlink(dirname(__FILE__) . '/_files/dumped.wsdl'); + } + + function testGetType() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', true); + + $this->assertEquals('xsd:string', $wsdl->getType('string'), 'xsd:string detection failed.'); + $this->assertEquals('xsd:string', $wsdl->getType('str'), 'xsd:string detection failed.'); + $this->assertEquals('xsd:int', $wsdl->getType('int'), 'xsd:int detection failed.'); + $this->assertEquals('xsd:int', $wsdl->getType('integer'), 'xsd:int detection failed.'); + $this->assertEquals('xsd:float', $wsdl->getType('float'), 'xsd:float detection failed.'); + $this->assertEquals('xsd:float', $wsdl->getType('double'), 'xsd:float detection failed.'); + $this->assertEquals('xsd:boolean', $wsdl->getType('boolean'), 'xsd:boolean detection failed.'); + $this->assertEquals('xsd:boolean', $wsdl->getType('bool'), 'xsd:boolean detection failed.'); + $this->assertEquals('soap-enc:Array', $wsdl->getType('array'), 'soap-enc:Array detection failed.'); + $this->assertEquals('xsd:struct', $wsdl->getType('object'), 'xsd:struct detection failed.'); + $this->assertEquals('xsd:anyType', $wsdl->getType('mixed'), 'xsd:anyType detection failed.'); + $this->assertEquals('', $wsdl->getType('void'), 'void detection failed.'); + } + + function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', true); + $this->assertEquals('tns:Zend_Soap_Wsdl_Test', $wsdl->getType('Zend_Soap_Wsdl_Test')); + $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_DefaultComplexType); + + $wsdl2 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', false); + $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_Wsdl_Test')); + $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType); + } + + function testGetComplexTypeBasedOnStrategiesStringNames() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_DefaultComplexType'); + $this->assertEquals('tns:Zend_Soap_Wsdl_Test', $wsdl->getType('Zend_Soap_Wsdl_Test')); + $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_DefaultComplexType); + + $wsdl2 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_AnyType'); + $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_Wsdl_Test')); + $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType); + } + + function testSettingUnknownStrategyThrowsException() + { + try { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_UnknownStrategyType'); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + function testSettingInvalidStrategyObjectThrowsException() + { + try { + $strategy = new Zend_Soap_Wsdl_Test(); + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $strategy); + $this->fail(); + } catch(Zend_Soap_Wsdl_Exception $e) { + + } + } + + function testAddingSameComplexTypeMoreThanOnceIsIgnored() + { + try { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl->addType('Zend_Soap_Wsdl_Test'); + $wsdl->addType('Zend_Soap_Wsdl_Test'); + $types = $wsdl->getTypes(); + $this->assertEquals(1, count($types)); + $this->assertEquals(array("Zend_Soap_Wsdl_Test"), $types); + } catch(Zend_Soap_Wsdl_Exception $e) { + $this->fail(); + } + } + + function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); + $this->assertEquals(array('Zend_Soap_Wsdl_Test'), $wsdl->getTypes()); + + $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); + $this->assertEquals(array('Zend_Soap_Wsdl_Test'), $wsdl->getTypes()); + } + + function testAddComplexType() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); + + $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + '' . + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' ); + } + + /** + * @group ZF-3910 + */ + function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $this->assertEquals("xsd:string", $wsdl->getType("StrIng")); + $this->assertEquals("xsd:string", $wsdl->getType("sTr")); + $this->assertEquals("xsd:int", $wsdl->getType("iNt")); + $this->assertEquals("xsd:int", $wsdl->getType("INTEGER")); + $this->assertEquals("xsd:float", $wsdl->getType("FLOAT")); + $this->assertEquals("xsd:float", $wsdl->getType("douBLE")); + } + + /** + * @group ZF-5430 + */ + public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceBySequenceStrategy() + { + $wsdl = new Zend_Soap_Wsdl("MyService", "http://localhost/MyService.php"); + $wsdl->setComplexTypeStrategy(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence()); + + $wsdl->addComplexType("string[]"); + $wsdl->addComplexType("int[]"); + $wsdl->addComplexType("string[]"); + + $xml = $wsdl->toXml(); + $this->assertEquals(1, substr_count($xml, "ArrayOfString"), "ArrayOfString should appear only once."); + $this->assertEquals(1, substr_count($xml, "ArrayOfInt"), "ArrayOfInt should appear only once."); + } + + const URI_WITH_EXPANDED_AMP = "http://localhost/MyService.php?a=b&b=c"; + const URI_WITHOUT_EXPANDED_AMP = "http://localhost/MyService.php?a=b&b=c"; + + /** + * @group ZF-5736 + */ + public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() + { + $wsdl = new Zend_Soap_Wsdl("MyService", self::URI_WITH_EXPANDED_AMP); + $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); + } + + /** + * @group ZF-5736 + */ + public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly() + { + $wsdl = new Zend_Soap_Wsdl("MyService", "http://example.com"); + $wsdl->setUri(self::URI_WITH_EXPANDED_AMP); + $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); + } +} + + + +/** + * Test Class + */ +class Zend_Soap_Wsdl_Test { + /** + * @var integer + */ + public $var1; + + /** + * @var string + */ + public $var2; +} \ No newline at end of file diff --git a/test/_files/cert_file b/test/_files/cert_file new file mode 100644 index 00000000..e69de29b diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php new file mode 100644 index 00000000..d2d2a196 --- /dev/null +++ b/test/_files/commontypes.php @@ -0,0 +1,338 @@ + 'bar', 'baz' => true, 1 => false, 'bat' => 123); +} + +/** + * Return Object + * + * @return StdClass + */ +function Zend_Soap_AutoDiscover_TestFunc8() +{ + $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false); + return $return; +} + +/** + * Multiple Args + * + * @param string $foo + * @param string $bar + * @return string + */ +function Zend_Soap_AutoDiscover_TestFunc9($foo, $bar) +{ + return "$foo $bar"; +} + +class Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes +{ + /** + * Test function + * + * @param integer $a + * @param integer $b + * @param integer $d + * @return integer + */ + function testFunc($a=100, $b=200, $d=300) + { + + } +} + +/** + * Test Class + */ +class Zend_Soap_AutoDiscover_Test { + /** + * Test Function 1 + * + * @return string + */ + function testFunc1() + { + return "Hello World"; + } + + /** + * Test Function 2 + * + * @param string $who Some Arg + * @return string + */ + function testFunc2($who) + { + return "Hello $who!"; + } + + /** + * Test Function 3 + * + * @param string $who Some Arg + * @param int $when Some + * @return string + */ + function testFunc3($who, $when) + { + return "Hello $who, How are you $when"; + } + + /** + * Test Function 4 + * + * @return string + */ + static function testFunc4() + { + return "I'm Static!"; + } +} + +class Zend_Soap_AutoDiscoverTestClass1 +{ + /** + * @var integer $var + */ + public $var = 1; + + /** + * @var string $param + */ + public $param = "hello"; +} + +class Zend_Soap_AutoDiscoverTestClass2 +{ + /** + * + * @param Zend_Soap_AutoDiscoverTestClass1 $test + * @return boolean + */ + public function add(Zend_Soap_AutoDiscoverTestClass1 $test) + { + return true; + } + + /** + * @return Zend_Soap_AutoDiscoverTestClass1[] + */ + public function fetchAll() + { + return array( + new Zend_Soap_AutoDiscoverTestClass1(), + new Zend_Soap_AutoDiscoverTestClass1(), + ); + } + + /** + * @param Zend_Soap_AutoDiscoverTestClass1[] + */ + public function addMultiple($test) + { + + } +} + + +class Zend_Soap_Wsdl_ComplexTypeB +{ + /** + * @var string + */ + public $bar; + /** + * @var string + */ + public $foo; +} + + +class Zend_Soap_Wsdl_ComplexTypeA +{ + /** + * @var Zend_Soap_Wsdl_ComplexTypeB[] + */ + public $baz = array(); +} + +class Zend_Soap_Wsdl_ComplexTest +{ + /** + * @var int + */ + public $var = 5; +} + +class Zend_Soap_Wsdl_ComplexObjectStructure +{ + /** + * @var boolean + */ + public $boolean = true; + + /** + * @var string + */ + public $string = "Hello World"; + + /** + * @var int + */ + public $int = 10; + + /** + * @var array + */ + public $array = array(1, 2, 3); +} + +class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure +{ + /** + * @var Zend_Soap_Wsdl_ComplexTest + */ + public $object; +} + +class Zend_Soap_AutoDiscover_MyService +{ + /** + * @param string $foo + * @return Zend_Soap_AutoDiscover_MyResponse[] + */ + public function foo($foo) { + } + /** + * @param string $bar + * @return Zend_Soap_AutoDiscover_MyResponse[] + */ + public function bar($bar) { + } + + /** + * @param string $baz + * @return Zend_Soap_AutoDiscover_MyResponse[] + */ + public function baz($baz) { + } +} + +class Zend_Soap_AutoDiscover_MyServiceSequence +{ + /** + * @param string $foo + * @return string[] + */ + public function foo($foo) { + } + /** + * @param string $bar + * @return string[] + */ + public function bar($bar) { + } + + /** + * @param string $baz + * @return string[] + */ + public function baz($baz) { + } + + /** + * @param string $baz + * @return string[][][] + */ + public function bazNested($baz) { + } +} + +class Zend_Soap_AutoDiscover_MyResponse +{ + /** + * @var string + */ + public $p1; +} + +class Zend_Soap_AutoDiscover_Recursion +{ + /** + * @var Zend_Soap_AutoDiscover_Recursion + */ + public $recursion; +} \ No newline at end of file diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php new file mode 100644 index 00000000..9a7da908 --- /dev/null +++ b/test/_files/fulltests/server1.php @@ -0,0 +1,61 @@ +bar = "bar"; + $b1->foo = "bar"; + $a->baz[] = $b1; + + $b2 = new Zend_Soap_Wsdl_ComplexTypeB(); + $b2->bar = "foo"; + $b2->foo = "foo"; + $a->baz[] = $b2; + + $a->baz[] = $request; + + return array($a); + } +} + +class Zend_Soap_Wsdl_ComplexTypeB +{ + /** + * @var string + */ + public $bar; + /** + * @var string + */ + public $foo; +} + + +class Zend_Soap_Wsdl_ComplexTypeA +{ + /** + * @var Zend_Soap_Wsdl_ComplexTypeB[] + */ + public $baz = array(); +} + +if(isset($_GET['wsdl'])) { + $server = new Zend_Soap_AutoDiscover(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex()); +} else { + $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; + $server = new Zend_Soap_Server($uri); +} +$server->setClass('Zend_Soap_Service_Server1'); +$server->handle(); \ No newline at end of file diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php new file mode 100644 index 00000000..5aa7987f --- /dev/null +++ b/test/_files/fulltests/server2.php @@ -0,0 +1,42 @@ +bar = $bar; + $b->foo = $foo; + return $b; + } +} + +if(isset($_GET['wsdl'])) { + $server = new Zend_Soap_AutoDiscover(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex()); +} else { + $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; + $server = new Zend_Soap_Server($uri); +} +$server->setClass('Zend_Soap_Service_Server2'); +$server->handle(); \ No newline at end of file diff --git a/test/_files/wsdl_documentation.wsdl b/test/_files/wsdl_documentation.wsdl new file mode 100644 index 00000000..5538eccd --- /dev/null +++ b/test/_files/wsdl_documentation.wsdl @@ -0,0 +1,106 @@ + + + Definitions + + + Ports + + + + + + + + + + + + + + + + + + + + Bindings + + + + + + + + + Operation1 + + + + + + + + + Operation2 + + + + + + + + + Operation3 + + + + + + + + + Operation4 + + + + + + + + + + + Services + + + + + + + + Message + + + + Message + + + + Message + + + + Message + + + + + Message + + + + + Message + + + \ No newline at end of file diff --git a/test/_files/wsdl_example.wsdl b/test/_files/wsdl_example.wsdl new file mode 100644 index 00000000..4eaa8761 --- /dev/null +++ b/test/_files/wsdl_example.wsdl @@ -0,0 +1,2 @@ + + diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 00000000..06072556 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + This type is extended by component types to allow them to be documented + + + + + + + + + + + + + This type is extended by component types to allow attributes from other namespaces to be added. + + + + + + + + + + + + + This type is extended by component types to allow elements from other namespaces to be added. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Any top level optional element allowed to appear more then once - any child of definitions element except wsdl:types. Any extensibility element is allowed in any place. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From e23de3325e2bbe34cca244cd9adb80db1c02bef7 Mon Sep 17 00:00:00 2001 From: beberlei Date: Sat, 30 May 2009 18:16:47 +0000 Subject: [PATCH 002/123] ZF-6497 - Fix relative pathes to Zend/ style git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15826 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/Abstract.php | 2 +- src/Wsdl/Strategy/AnyType.php | 2 +- src/Wsdl/Strategy/ArrayOfTypeSequence.php | 2 +- src/Wsdl/Strategy/Composite.php | 2 ++ src/Wsdl/Strategy/DefaultComplexType.php | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Wsdl/Strategy/Abstract.php b/src/Wsdl/Strategy/Abstract.php index 59bb0831..45415982 100644 --- a/src/Wsdl/Strategy/Abstract.php +++ b/src/Wsdl/Strategy/Abstract.php @@ -20,7 +20,7 @@ * @version $Id$ */ -require_once "Interface.php"; +require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; /** * Abstract class for Zend_Soap_Wsdl_Strategy. diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php index 058c6665..390879cd 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -20,7 +20,7 @@ * @version $Id$ */ -require_once "Interface.php"; +require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface { diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php index 06579b62..e13d6f1d 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -19,7 +19,7 @@ * @version $Id$ */ -require_once "Abstract.php"; +require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_Abstract { diff --git a/src/Wsdl/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php index f3714342..31aafebf 100644 --- a/src/Wsdl/Strategy/Composite.php +++ b/src/Wsdl/Strategy/Composite.php @@ -20,6 +20,8 @@ * @version $Id$ */ +require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; + class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface { /** diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index 56f5bff9..cff016f2 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -20,7 +20,7 @@ * @version $Id$ */ -require_once "Abstract.php"; +require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract { From 1211786e05fad2a7c39e6a2abc9d3a34ee55c154 Mon Sep 17 00:00:00 2001 From: beberlei Date: Sat, 30 May 2009 19:03:02 +0000 Subject: [PATCH 003/123] ZF-6346 - has to be the first element of each child-set. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15828 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl.php | 20 +++++++++----- test/WsdlTest.php | 68 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/src/Wsdl.php b/src/Wsdl.php index ef3f1f6d..0a92c7cd 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -390,11 +390,15 @@ public function addService($name, $port_name, $binding, $location) } /** - * Add a {@link http://www.w3.org/TR/wsdl#_documentation document} element to any element in the WSDL + * Add a documentation element to any element in the WSDL. * - * @param object $input_node An XML_Tree_Node returned by another method to add the document to - * @param string $document Human readable documentation for the node - * @return boolean + * Note that the WSDL {@link http://www.w3.org/TR/wsdl#_documentation specification} uses 'document', + * but the WSDL {@link http://schemas.xmlsoap.org/wsdl/ schema} uses 'documentation' instead. + * The {@link http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#WSDL_documentation_Element WS-I Basic Profile 1.1} recommends using 'documentation'. + * + * @param object $input_node An XML_Tree_Node returned by another method to add the documentation to + * @param string $documentation Human readable documentation for the node + * @return DOMElement The documentation element */ public function addDocumentation($input_node, $documentation) { @@ -404,11 +408,15 @@ public function addDocumentation($input_node, $documentation) $node = $input_node; } - /** @todo Check if 'documentation' is a correct name for the element (WSDL spec uses 'document') */ $doc = $this->_dom->createElement('documentation'); $doc_cdata = $this->_dom->createTextNode($documentation); $doc->appendChild($doc_cdata); - $node->appendChild($doc); + + if($node->hasChildNodes()) { + $node->insertBefore($doc, $node->firstChild); + } else { + $node->appendChild($doc); + } return $doc; } diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 7d4cb8d6..29d76f67 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -26,7 +26,7 @@ */ class Zend_Soap_WsdlTest extends PHPUnit_Framework_TestCase { - protected function sanatizeWsdlXmlOutputForOsCompability($xmlstring) + protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) { $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring); $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); @@ -37,7 +37,7 @@ function testConstructor() { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'setUri('http://localhost/MyNewService.php'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addMessage('myMessage', $messageParts); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortOperation($portType, 'operation2', 'tns:operation2Request', 'tns:operation2Response'); $wsdl->addPortOperation($portType, 'operation3', 'tns:operation3Request', 'tns:operation3Response', 'tns:operation3Fault'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . ' 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . ' 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . ' 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl1->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl1->toXml()), '' . ' 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addDocumentation($portType, 'This is a description for Port Type node.'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . '' ); } + public function testAddDocumentationToSetInsertsBefore() + { + $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + + $messageParts = array(); + $messageParts['parameter1'] = $wsdl->getType('int'); + $messageParts['parameter2'] = $wsdl->getType('string'); + $messageParts['parameter3'] = $wsdl->getType('mixed'); + + $message = $wsdl->addMessage('myMessage', $messageParts); + $wsdl->addDocumentation($message, "foo"); + + $this->assertEquals( + '' . + '' + . '' + . 'foo' + . '' + . '' + . '' + . '' + . '', + $this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()) + ); + } + function testToXml() { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'assertTrue($dom instanceOf DOMDocument); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), '' . 'assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdlDump), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdlDump), '' . 'dump(dirname(__FILE__) . '/_files/dumped.wsdl'); $dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($dumpedContent), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dumpedContent), '' . 'addComplexType('Zend_Soap_Wsdl_Test'); - $this->assertEquals($this->sanatizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . ' Date: Sat, 30 May 2009 19:33:10 +0000 Subject: [PATCH 004/123] ZF-6689 - Functions and Methods with @return void are now interpreted as One-Way messages in WSDL AutoDiscover git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15830 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 37 +++++++++++++++++++++++++++---------- test/AutoDiscoverTest.php | 34 ++++++++++++++++++++++++++++++++-- test/_files/commontypes.php | 20 ++++++++++++++++++++ 3 files changed, 79 insertions(+), 12 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index ab53d2a3..f234fda1 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -260,15 +260,6 @@ public function setClass($class, $namespace = '', $argv = null) $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { - /* 's */ - $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response'); - $desc = $method->getDescription(); - if (strlen($desc) > 0) { - /** @todo check, what should be done for portoperation documentation */ - //$wsdl->addDocumentation($portOperation, $desc); - } - /* 's */ - $this->_functions[] = $method->getName(); $selectedPrototype = null; @@ -283,6 +274,27 @@ public function setClass($class, $namespace = '', $argv = null) if($selectedPrototype != null) { $prototype = $selectedPrototype; + + $isOneWayCall = false; + if ($prototype->getReturnType() == "void") { + $isOneWayCall = true; + } + + if($isOneWayCall == true) { + $responseMessage = false; + } else { + $responseMessage = 'tns:' .$method->getName(). 'Response'; + } + + /* 's */ + $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', $responseMessage); + $desc = $method->getDescription(); + if (strlen($desc) > 0) { + /** @todo check, what should be done for portoperation documentation */ + //$wsdl->addDocumentation($portOperation, $desc); + } + /* 's */ + $args = array(); foreach($prototype->getParameters() as $param) { $args[$param->getName()] = $wsdl->getType($param->getType()); @@ -349,12 +361,17 @@ public function addFunction($function, $namespace = '') if (strlen($desc) > 0) { //$wsdl->addDocumentation($message, $desc); } + if($prototype->getReturnType() != "void") { + $responseMessage = 'tns:' .$method->getName(). 'Response'; $returnName = "return"; $message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType()))); + } else { + $responseMessage = false; } + /* 's */ - $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response'); + $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', $responseMessage); if (strlen($desc) > 0) { //$wsdl->addDocumentation($portOperation, $desc); } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 24d69a07..44e82da5 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -383,7 +383,7 @@ function testAddFunctionMultiple() ''. ''. ''. - ''. + ''. ''. ''. ''. @@ -455,7 +455,7 @@ function testAddFunctionMultiple() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/addfunction2.wsdl'); @@ -778,4 +778,34 @@ public function testAmpersandInUrlIsCorrectlyEncoded() $this->assertContains("http://example.com/?a=b&b=c", $wsdl); } + + /** + * @group ZF-6689 + */ + public function testNoReturnIsOneWayCallInSetClass() + { + $autodiscover = new Zend_Soap_AutoDiscover(); + $autodiscover->setClass('Zend_Soap_AutoDiscover_NoReturnType'); + $wsdl = $autodiscover->toXml(); + + $this->assertContains( + '', + $wsdl + ); + } + + /** + * @group ZF-6689 + */ + public function testNoReturnIsOneWayCallInAddFunction() + { + $autodiscover = new Zend_Soap_AutoDiscover(); + $autodiscover->addFunction('Zend_Soap_AutoDiscover_OneWay'); + $wsdl = $autodiscover->toXml(); + + $this->assertContains( + '', + $wsdl + ); + } } \ No newline at end of file diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index d2d2a196..c436f07d 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -335,4 +335,24 @@ class Zend_Soap_AutoDiscover_Recursion * @var Zend_Soap_AutoDiscover_Recursion */ public $recursion; +} + +/** + * @param string $message + */ +function Zend_Soap_AutoDiscover_OneWay($message) +{ + +} + +class Zend_Soap_AutoDiscover_NoReturnType +{ + /** + * + * @param string $message + */ + public function pushOneWay($message) + { + + } } \ No newline at end of file From 5a75388f2afaed0367f37959ecc598b41d079c2c Mon Sep 17 00:00:00 2001 From: beberlei Date: Sat, 30 May 2009 22:37:41 +0000 Subject: [PATCH 005/123] ZF-6348 and ZF-6349 (Closing additional sideeffect issueZF-6049) - Refactored patches of Fabien Crespel that greatly enhance Zend_Soap_AutoDiscover interoperability with non-PHP SOAP Client Generators such as WSImport git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15832 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 202 ++++++++++++++----------- src/Wsdl.php | 71 ++++++++- test/AutoDiscoverTest.php | 306 ++++++++++++++++++++++++-------------- 3 files changed, 384 insertions(+), 195 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index f234fda1..8a771ed5 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -254,65 +254,16 @@ public function setClass($class, $namespace = '', $argv = null) $wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy); + // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) + $wsdl->addSchemaTypeSection(); + $port = $wsdl->addPortType($class . 'Port'); $binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port'); $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { - $this->_functions[] = $method->getName(); - - $selectedPrototype = null; - $maxNumArgumentsOfPrototype = -1; - foreach ($method->getPrototypes() as $prototype) { - $numParams = count($prototype->getParameters()); - if($numParams > $maxNumArgumentsOfPrototype) { - $maxNumArgumentsOfPrototype = $numParams; - $selectedPrototype = $prototype; - } - } - - if($selectedPrototype != null) { - $prototype = $selectedPrototype; - - $isOneWayCall = false; - if ($prototype->getReturnType() == "void") { - $isOneWayCall = true; - } - - if($isOneWayCall == true) { - $responseMessage = false; - } else { - $responseMessage = 'tns:' .$method->getName(). 'Response'; - } - - /* 's */ - $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', $responseMessage); - $desc = $method->getDescription(); - if (strlen($desc) > 0) { - /** @todo check, what should be done for portoperation documentation */ - //$wsdl->addDocumentation($portOperation, $desc); - } - /* 's */ - - $args = array(); - foreach($prototype->getParameters() as $param) { - $args[$param->getName()] = $wsdl->getType($param->getType()); - } - $message = $wsdl->addMessage($method->getName() . 'Request', $args); - if (strlen($desc) > 0) { - //$wsdl->addDocumentation($message, $desc); - } - if ($prototype->getReturnType() != "void") { - $returnName = 'return'; - $message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType()))); - } - - /* 's */ - $operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); - $wsdl->addSoapOperation($operation, $uri . '#' .$method->getName()); - /* 's */ - } + $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; } @@ -340,6 +291,9 @@ public function addFunction($function, $namespace = '') $name = $parts[0]; $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy); + // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) + $wsdl->addSchemaTypeSection(); + $port = $wsdl->addPortType($name . 'Port'); $binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port'); @@ -351,44 +305,120 @@ public function addFunction($function, $namespace = '') foreach ($function as $func) { $method = $this->_reflection->reflectFunction($func); - foreach ($method->getPrototypes() as $prototype) { - $args = array(); - foreach ($prototype->getParameters() as $param) { - $args[$param->getName()] = $wsdl->getType($param->getType()); - } - $message = $wsdl->addMessage($method->getName() . 'Request', $args); - $desc = $method->getDescription(); - if (strlen($desc) > 0) { - //$wsdl->addDocumentation($message, $desc); - } - - if($prototype->getReturnType() != "void") { - $responseMessage = 'tns:' .$method->getName(). 'Response'; - $returnName = "return"; - $message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType()))); - } else { - $responseMessage = false; - } - - /* 's */ - $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', $responseMessage); - if (strlen($desc) > 0) { - //$wsdl->addDocumentation($portOperation, $desc); - } - /* 's */ + $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); + } + $this->_wsdl = $wsdl; + } - /* 's */ - $operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); - $wsdl->addSoapOperation($operation, $uri . '#' .$method->getName()); - /* 's */ + /** + * Add a function to the WSDL document. + * + * @param $function Zend_Server_Reflection_Function_Abstract function to add + * @param $wsdl Zend_Soap_Wsdl WSDL document + * @param $port object wsdl:portType + * @param $binding object wsdl:binding + * @return void + */ + protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) + { + $uri = $this->getUri(); - $this->_functions[] = $method->getName(); + // We only support one prototype: the one with the maximum number of arguments + $prototype = null; + $maxNumArgumentsOfPrototype = -1; + foreach ($function->getPrototypes() as $tmpPrototype) { + $numParams = count($tmpPrototype->getParameters()); + if ($numParams > $maxNumArgumentsOfPrototype) { + $maxNumArgumentsOfPrototype = $numParams; + $prototype = $tmpPrototype; + } + } + if ($prototype === null) { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("No prototypes could be found for the '" . $function->getName() . "' function"); + } - // We will only add one prototype - break; + // Add the input message (parameters) + $args = array(); + if ($this->_bindingStyle['style'] == 'document') { + // Document style: wrap all parameters in a sequence element + $sequence = array(); + foreach ($prototype->getParameters() as $param) { + $sequenceElement = array( + 'name' => $param->getName(), + 'type' => $wsdl->getType($param->getType()) + ); + if ($param->isOptional()) { + $sequenceElement['nillable'] = 'true'; + } + $sequence[] = $sequenceElement; + } + $element = array( + 'name' => $function->getName(), + 'sequence' => $sequence + ); + // Add the wrapper element part, which must be named 'parameters' + $args['parameters'] = array('element' => $wsdl->addElement($element)); + } else { + // RPC style: add each parameter as a typed part + foreach ($prototype->getParameters() as $param) { + $args[$param->getName()] = array('type' => $wsdl->getType($param->getType())); } } - $this->_wsdl = $wsdl; + $wsdl->addMessage($function->getName() . 'In', $args); + + $isOneWayMessage = false; + if($prototype->getReturnType() == "void") { + $isOneWayMessage = true; + } + + if($isOneWayMessage == false) { + // Add the output message (return value) + $args = array(); + if ($this->_bindingStyle['style'] == 'document') { + // Document style: wrap the return value in a sequence element + $sequence = array(); + if ($prototype->getReturnType() != "void") { + $sequence[] = array( + 'name' => $function->getName() . 'Result', + 'type' => $wsdl->getType($prototype->getReturnType()) + ); + } + $element = array( + 'name' => $function->getName() . 'Response', + 'sequence' => $sequence + ); + // Add the wrapper element part, which must be named 'parameters' + $args['parameters'] = array('element' => $wsdl->addElement($element)); + } else if ($prototype->getReturnType() != "void") { + // RPC style: add the return value as a typed part + $args['return'] = array('type' => $wsdl->getType($prototype->getReturnType())); + } + $wsdl->addMessage($function->getName() . 'Out', $args); + } + + // Add the portType operation + if($isOneWayMessage == false) { + $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', 'tns:' . $function->getName() . 'Out'); + } else { + $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', false); + } + $desc = $function->getDescription(); + if (strlen($desc) > 0) { + $wsdl->addDocumentation($portOperation, $desc); + } + + // When using the RPC style, make sure the operation style includes a 'namespace' attribute (WS-I Basic Profile 1.1 R2717) + if ($this->_bindingStyle['style'] == 'rpc' && !isset($this->_operationBodyStyle['namespace'])) { + $this->_operationBodyStyle['namespace'] = ''.$uri; + } + + // Add the binding operation + $operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); + $wsdl->addSoapOperation($operation, $uri . '#' .$function->getName()); + + // Add the function name to the list + $this->_functions[] = $function->getName(); } /** diff --git a/src/Wsdl.php b/src/Wsdl.php index 0a92c7cd..8117f281 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -175,6 +175,8 @@ public function getComplexTypeStrategy() * @param string $name Name for the {@link http://www.w3.org/TR/wsdl#_messages message} * @param array $parts An array of {@link http://www.w3.org/TR/wsdl#_message parts} * The array is constructed like: 'name of part' => 'part xml schema data type' + * or 'name of part' => array('type' => 'part xml schema type') + * or 'name of part' => array('element' => 'part xml element name') * @return object The new message's XML_Tree_Node for use in {@link function addDocumentation} */ public function addMessage($name, $parts) @@ -187,7 +189,13 @@ public function addMessage($name, $parts) foreach ($parts as $name => $type) { $part = $this->_dom->createElement('part'); $part->setAttribute('name', $name); - $part->setAttribute('type', $type); + if (is_array($type)) { + foreach ($type as $key => $value) { + $part->setAttribute($key, $value); + } + } else { + $part->setAttribute('type', $type); + } $message->appendChild($part); } } @@ -587,4 +595,65 @@ public function addComplexType($type) // delegates the detection of a complex type to the current strategy return $strategy->addComplexType($type); } + + /** + * Parse an xsd:element represented as an array into a DOMElement. + * + * @param array $element an xsd:element represented as an array + * @return DOMElement parsed element + */ + private function _parseElement($element) + { + if (!is_array($element)) { + require_once "Zend/Soap/Wsdl/Exception.php"; + throw new Zend_Soap_Wsdl_Exception("The 'element' parameter needs to be an associative array."); + } + + $elementXml = $this->_dom->createElement('xsd:element'); + foreach ($element as $key => $value) { + if (in_array($key, array('sequence', 'all', 'choice'))) { + if (is_array($value)) { + $complexType = $this->_dom->createElement('xsd:complexType'); + if (count($value) > 0) { + $container = $this->_dom->createElement('xsd:' . $key); + foreach ($value as $subelement) { + $subelementXml = $this->_parseElement($subelement); + $container->appendChild($subelementXml); + } + $complexType->appendChild($container); + } + $elementXml->appendChild($complexType); + } + } else { + $elementXml->setAttribute($key, $value); + } + } + return $elementXml; + } + + /** + * Add an xsd:element represented as an array to the schema. + * + * Array keys represent attribute names and values their respective value. + * The 'sequence', 'all' and 'choice' keys must have an array of elements as their value, + * to add them to a nested complexType. + * + * Example: array( 'name' => 'MyElement', + * 'sequence' => array( array('name' => 'myString', 'type' => 'string'), + * array('name' => 'myInteger', 'type' => 'int') ) ); + * Resulting XML: + * + * + * + * + * @param array $element an xsd:element represented as an array + * @return string xsd:element for the given element array + */ + public function addElement($element) + { + $schema = $this->getSchema(); + $elementXml = $this->_parseElement($element); + $schema->appendChild($elementXml); + return 'tns:' . $element['name']; + } } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 44e82da5..8d30c9bb 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -42,7 +42,7 @@ public function setUp() $_SERVER['HTTPS'] = "off"; } - protected function sanatizeWsdlXmlOutputForOsCompability($xmlstring) + protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) { $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring); $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); @@ -69,44 +69,51 @@ function testSetClass() . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' . 'name="Zend_Soap_AutoDiscover_Test" ' . 'targetNamespace="' . $scriptUri . '">' + . '' + . '' + . '' . '' . '' - . '' - . '' + . 'Test Function 1' + . '' + . '' . '' . '' - . '' - . '' + . 'Test Function 2' + . '' + . '' . '' . '' - . '' - . '' + . 'Test Function 3' + . '' + . '' . '' - . '' - . '' + . 'Test Function 4' + . '' + . '' . '' . '' . '' . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -114,18 +121,18 @@ function testSetClass() . '' . '' . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' . ''; $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/setclass.wsdl'); @@ -153,21 +160,78 @@ function testSetClassWithDifferentStyles() . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' . 'name="Zend_Soap_AutoDiscover_Test" ' . 'targetNamespace="' . $scriptUri . '">' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' . '' . '' - . '' - . '' + . 'Test Function 1' + . '' + . '' . '' . '' - . '' - . '' + . 'Test Function 2' + . '' + . '' . '' . '' - . '' - . '' + . 'Test Function 3' + . '' + . '' . '' - . '' - . '' + . 'Test Function 4' + . '' + . '' . '' . '' . '' @@ -198,18 +262,34 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' . ''; $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/setclass.wsdl'); @@ -230,10 +310,10 @@ function testSetClassWithResponseReturnPartCompabilityMode() $dom->loadXML(ob_get_clean()); $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanatizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); unlink(dirname(__FILE__).'/_files/setclass.wsdl'); } @@ -257,15 +337,16 @@ function testAddFunctionSimple() $wsdl = ''. ''. + ''. ''. - ''. + 'Test Function'. ''. ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -273,10 +354,10 @@ function testAddFunctionSimple() ''. ''. ''. - ''. - ''. + ''. + ''. ''; - $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); @@ -302,8 +383,14 @@ function testAddFunctionSimpleWithDifferentStyle() $wsdl = ''. ''. + ''. + ''. + ''. + ''. + ''. + ''. ''. - ''. + 'Test Function'. ''. ''. ''. @@ -318,10 +405,10 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''. - ''. + ''. + ''. ''; - $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); @@ -346,9 +433,9 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; - $wsdl = $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()); - $this->assertContains('', $wsdl); - $this->assertNotContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()); + $this->assertContains('', $wsdl); + $this->assertNotContains('assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); @@ -381,57 +468,58 @@ function testAddFunctionMultiple() $wsdl = ''. ''. + ''. ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + 'Test Function'. + 'Test Function 2'. + 'Return false'. + 'Return true'. + 'Return integer'. + 'Return string'. + 'Return array'. + 'Multiple Args'. ''. ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -439,25 +527,27 @@ function testAddFunctionMultiple() ''. ''. ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''; - $this->assertEquals($wsdl, $this->sanatizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + + unlink(dirname(__FILE__).'/_files/addfunction2.wsdl'); } @@ -578,8 +668,8 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() $wsdlOutput = ob_get_contents(); ob_end_clean(); - $this->assertEquals(1, substr_count($wsdlOutput, '')); - $this->assertEquals(1, substr_count($wsdlOutput, '')); + $this->assertEquals(1, substr_count($wsdlOutput, '')); + $this->assertEquals(1, substr_count($wsdlOutput, '')); } public function testUnusedFunctionsOfAutoDiscoverThrowException() @@ -699,8 +789,8 @@ public function testDumpOrXmlOfAutoDiscover() ob_end_clean(); $this->assertEquals( - $this->sanatizeWsdlXmlOutputForOsCompability($wsdlOutput), - $this->sanatizeWsdlXmlOutputForOsCompability($server->toXml()) + $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), + $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) ); ob_start(); @@ -709,8 +799,8 @@ public function testDumpOrXmlOfAutoDiscover() ob_end_clean(); $this->assertEquals( - $this->sanatizeWsdlXmlOutputForOsCompability($wsdlOutput), - $this->sanatizeWsdlXmlOutputForOsCompability($server->toXml()) + $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), + $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) ); } @@ -789,7 +879,7 @@ public function testNoReturnIsOneWayCallInSetClass() $wsdl = $autodiscover->toXml(); $this->assertContains( - '', + '@param string $message', $wsdl ); } @@ -804,7 +894,7 @@ public function testNoReturnIsOneWayCallInAddFunction() $wsdl = $autodiscover->toXml(); $this->assertContains( - '', + '@param string $message', $wsdl ); } From 43c0c48148ca8bfba88ce4e3048f8fbadb1973a3 Mon Sep 17 00:00:00 2001 From: beberlei Date: Thu, 11 Jun 2009 09:58:15 +0000 Subject: [PATCH 006/123] ZF-6955 - Added missing Zend_Soap_Client::setCookie method which proxies to SoapClient git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15994 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client.php | 48 +++++++++++++++++++++++++++++++++++---------- test/ClientTest.php | 29 +++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/src/Client.php b/src/Client.php index 3b0adb2c..d69316cf 100644 --- a/src/Client.php +++ b/src/Client.php @@ -814,6 +814,8 @@ public function getStreamContext() public function setSoapFeatures($feature) { $this->_features = $feature; + + $this->_soapClient = null; return $this; } @@ -1048,14 +1050,12 @@ public function getLastSoapOutputHeaderObjects() */ public function __call($name, $arguments) { - if ($this->_soapClient == null) { - $this->_initSoapClientObject(); - } + $soapClient = $this->getSoapClient(); $this->_lastMethod = $name; $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders); - $result = $this->_soapClient->__soapCall($name, + $result = $soapClient->__soapCall($name, $this->_preProcessArguments($arguments), null, /* Options are already set to the SOAP client object */ (count($soapHeaders) > 0)? $soapHeaders : null, @@ -1081,11 +1081,8 @@ public function getFunctions() throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); } - if ($this->_soapClient == null) { - $this->_initSoapClientObject(); - } - - return $this->_soapClient->__getFunctions(); + $soapClient = $this->getSoapClient(); + return $soapClient->__getFunctions(); } @@ -1108,10 +1105,41 @@ public function getTypes() throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); } + $soapClient = $this->getSoapClient(); + + return $soapClient->__getTypes(); + } + + /** + * @param SoapClient $soapClient + * @return Zend_Soap_Client + */ + public function setSoapClient(SoapClient $soapClient) + { + $this->_soapClient = $soapClient; + return $this; + } + + /** + * @return SoapClient + */ + public function getSoapClient() + { if ($this->_soapClient == null) { $this->_initSoapClientObject(); } + return $this->_soapClient; + } - return $this->_soapClient->__getTypes(); + /** + * @param string $name + * @param string $value + * @return Zend_Soap_Client + */ + public function setCookie($cookieName, $cookieValue=null) + { + $soapClient = $this->getSoapClient(); + $soapClient->__setCookie($cookieName, $cookieValue); + return $this; } } diff --git a/test/ClientTest.php b/test/ClientTest.php index b62945bc..8f31a2aa 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -362,6 +362,35 @@ public function testSetInputHeaders() $this->assertEquals($client->getLastRequest(), $expectedRequest); } + + /** + * @group ZF-6955 + */ + public function testSetCookieIsDelegatedToSoapClient() + { + $fixtureCookieKey = "foo"; + $fixtureCookieValue = "bar"; + + $clientMock = $this->getMock('SoapClient', array('__setCookie'), array(null, array('uri' => 'http://www.zend.com', 'location' => 'http://www.zend.com'))); + $clientMock->expects($this->once()) + ->method('__setCookie') + ->with($fixtureCookieKey, $fixtureCookieValue); + + $soap = new Zend_Soap_Client(); + $soap->setSoapClient($clientMock); + + $soap->setCookie($fixtureCookieKey, $fixtureCookieValue); + } + + public function testSetSoapClient() + { + $clientMock = $this->getMock('SoapClient', array('__setCookie'), array(null, array('uri' => 'http://www.zend.com', 'location' => 'http://www.zend.com'))); + + $soap = new Zend_Soap_Client(); + $soap->setSoapClient($clientMock); + + $this->assertSame($clientMock, $soap->getSoapClient()); + } } From 8a20c2404f1782393ba73e549c5d48d4fdb4547d Mon Sep 17 00:00:00 2001 From: thomas Date: Sun, 21 Jun 2009 19:22:17 +0000 Subject: [PATCH 007/123] [ZF-6295] Generic: - fixed license date (partitial) git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16210 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 2 +- src/AutoDiscover/Exception.php | 2 +- src/Client.php | 4 ++-- src/Client/Common.php | 2 +- src/Client/DotNet.php | 2 +- src/Client/Exception.php | 4 ++-- src/Client/Local.php | 2 +- src/Server.php | 4 ++-- src/Server/Exception.php | 4 ++-- src/Wsdl.php | 2 +- src/Wsdl/Exception.php | 2 +- src/Wsdl/Strategy/Abstract.php | 4 ++-- src/Wsdl/Strategy/AnyType.php | 2 +- src/Wsdl/Strategy/ArrayOfTypeComplex.php | 2 +- src/Wsdl/Strategy/ArrayOfTypeSequence.php | 2 +- src/Wsdl/Strategy/Composite.php | 2 +- src/Wsdl/Strategy/DefaultComplexType.php | 2 +- src/Wsdl/Strategy/Interface.php | 2 +- 18 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 8a771ed5..d0b6072b 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage AutoDiscover - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php index 144bb75b..da3fbae5 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/AutoDiscover/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage AutoDiscover - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/src/Client.php b/src/Client.php index d69316cf..92be4fcd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Client diff --git a/src/Client/Common.php b/src/Client/Common.php index 02ee9352..b328feb1 100644 --- a/src/Client/Common.php +++ b/src/Client/Common.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index e0d085cc..4c24b7d7 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/src/Client/Exception.php b/src/Client/Exception.php index 5dafac0c..33e79d7b 100644 --- a/src/Client/Exception.php +++ b/src/Client/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $ */ diff --git a/src/Client/Local.php b/src/Client/Local.php index 05e731d6..2c7f74b0 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/src/Server.php b/src/Server.php index 70b65de9..9a1f2abd 100644 --- a/src/Server.php +++ b/src/Server.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Server - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,7 +31,7 @@ * @package Zend_Soap * @subpackage Server * @uses Zend_Server_Interface - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Server/Exception.php b/src/Server/Exception.php index 9df51f88..86bffddd 100644 --- a/src/Server/Exception.php +++ b/src/Server/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Server - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @category Zend * @package Zend_Soap * @subpackage Server - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl.php b/src/Wsdl.php index 8117f281..014c0470 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Exception.php b/src/Wsdl/Exception.php index a0dbe211..804dd5b5 100644 --- a/src/Wsdl/Exception.php +++ b/src/Wsdl/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Strategy/Abstract.php b/src/Wsdl/Strategy/Abstract.php index 45415982..d2e05feb 100644 --- a/src/Wsdl/Strategy/Abstract.php +++ b/src/Wsdl/Strategy/Abstract.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -28,7 +28,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Soap_Wsdl_Strategy_Abstract implements Zend_Soap_Wsdl_Strategy_Interface diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php index 390879cd..3c89dab7 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php index 0142265e..3253fe91 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php index e13d6f1d..c3bf65be 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php index 31aafebf..6e3f9a3b 100644 --- a/src/Wsdl/Strategy/Composite.php +++ b/src/Wsdl/Strategy/Composite.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index cff016f2..b7c9196b 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Strategy/Interface.php b/src/Wsdl/Strategy/Interface.php index d104bbf8..7175f169 100644 --- a/src/Wsdl/Strategy/Interface.php +++ b/src/Wsdl/Strategy/Interface.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ From ec1e1ed4d747339d1feaa742622073c7f931c070 Mon Sep 17 00:00:00 2001 From: thomas Date: Sun, 21 Jun 2009 20:34:55 +0000 Subject: [PATCH 008/123] [ZF-6295] Generic: - fixed license date (partitial) THE LAST COMMIT... HONESTLY :-) git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16225 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/ClientTest.php | 2 +- test/ServerTest.php | 4 ++-- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 2 +- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 2 +- test/Wsdl/CompositeStrategyTest.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/ClientTest.php b/test/ClientTest.php index 8f31a2aa..b06c5776 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/ServerTest.php b/test/ServerTest.php index 55ee4bf9..e6b61506 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -36,7 +36,7 @@ * @category Zend * @package UnitTests * @uses Zend_Server_Interface - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 0b800738..268c9568 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index ef0fd204..ec23c26e 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php index 9564bc4b..1f7dccc9 100644 --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ From b43e9ea8425af1c20ce4961fd446daf4cd9524d9 Mon Sep 17 00:00:00 2001 From: bkarwin Date: Tue, 7 Jul 2009 06:59:03 +0000 Subject: [PATCH 009/123] ZF-507 update @copyright and other tags git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16541 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover/Exception.php | 3 ++- src/Client.php | 1 + src/Client/Common.php | 1 + src/Client/DotNet.php | 1 + src/Client/Local.php | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php index da3fbae5..010c4a3e 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/AutoDiscover/Exception.php @@ -17,6 +17,7 @@ * @subpackage AutoDiscover * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ */ require_once "Zend/Exception.php"; @@ -27,4 +28,4 @@ */ class Zend_Soap_AutoDiscover_Exception extends Zend_Exception { -} \ No newline at end of file +} diff --git a/src/Client.php b/src/Client.php index 92be4fcd..c717d8f8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -17,6 +17,7 @@ * @subpackage Client * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ */ /** Zend_Soap_Server */ diff --git a/src/Client/Common.php b/src/Client/Common.php index b328feb1..b4eb28e8 100644 --- a/src/Client/Common.php +++ b/src/Client/Common.php @@ -17,6 +17,7 @@ * @subpackage Client * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ */ diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 4c24b7d7..405f5d31 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -17,6 +17,7 @@ * @subpackage Client * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ */ /** Zend_Soap_Client */ diff --git a/src/Client/Local.php b/src/Client/Local.php index 2c7f74b0..685c92ea 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -17,6 +17,7 @@ * @subpackage Client * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id$ */ /** Zend_Soap_Server */ From 5faf1f180a4527bbf6ef892017507af9cb72ecf1 Mon Sep 17 00:00:00 2001 From: matthew Date: Sun, 19 Jul 2009 13:38:36 +0000 Subject: [PATCH 010/123] [TESTS] Audit of full test suite Completed full audit of test suite, and tests now run with changes. Output buffering is now disabled by default, which allows tests to run with much less memory, and report in real-time. There are a number of failures and errors still, and I have a list I will be working on and/or delegating to the appropriate component authors. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16852 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/AutoDiscoverTest.php | 5 ++++- test/ClientTest.php | 38 ++++++++++++++++++++++++++++++++++++++ test/ServerTest.php | 22 +++++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 8d30c9bb..3f2633f8 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -59,6 +59,7 @@ function testSetClass() ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); + ob_end_clean(); $wsdl = '' . 'handle(); $dom->loadXML(ob_get_clean()); + ob_end_clean(); $wsdl = '' . 'handle(); $dom->loadXML(ob_get_clean()); + ob_end_clean(); $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); @@ -898,4 +901,4 @@ public function testNoReturnIsOneWayCallInAddFunction() $wsdl ); } -} \ No newline at end of file +} diff --git a/test/ClientTest.php b/test/ClientTest.php index b06c5776..cb571141 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -18,6 +18,10 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Zend_Soap_ClientTest::main'); +} + require_once dirname(__FILE__)."/../../TestHelper.php"; /** PHPUnit Test Case */ @@ -40,6 +44,17 @@ */ class Zend_Soap_ClientTest extends PHPUnit_Framework_TestCase { + /** + * Runs this test suite + * + * @return void + */ + public static function main() + { + $suite = new PHPUnit_Framework_TestSuite(__CLASS__); + $result = PHPUnit_TextUI_TestRunner::run($suite); + } + public function setUp() { if (!extension_loaded('soap')) { @@ -180,6 +195,11 @@ public function testGetTypes() public function testGetLastRequest() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testGetLastRequest() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); @@ -205,6 +225,11 @@ public function testGetLastRequest() public function testGetLastResponse() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testGetLastResponse() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); @@ -231,6 +256,11 @@ public function testGetLastResponse() public function testCallInvoke() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testCallInvoke() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); @@ -277,6 +307,11 @@ public function testSetOptionsWithZendConfig() public function testSetInputHeaders() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testSetInputHeaders() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); @@ -536,3 +571,6 @@ function Zend_Soap_Client_TestFunc6() return "string"; } +if (PHPUnit_MAIN_METHOD == 'Zend_Soap_ClientTest::main') { + Zend_Soap_ClientTest::main(); +} diff --git a/test/ServerTest.php b/test/ServerTest.php index e6b61506..f6dbf0fc 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -512,6 +512,11 @@ public function testGetPersistence() public function testGetLastRequest() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testGetLastRequest() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -563,6 +568,11 @@ public function testGetReturnResponse() public function testGetLastResponse() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testGetLastResponse() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -606,6 +616,11 @@ public function testGetLastResponse() public function testHandle() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run testHandle() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); @@ -783,6 +798,11 @@ public function testLoadFunctionsIsNotImplemented() public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHandleMode() { + if (headers_sent()) { + $this->markTestSkipped('Cannot run ' . __METHOD__ . '() when headers have already been sent; enable output buffering to run this test'); + return; + } + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -1046,4 +1066,4 @@ function Zend_Soap_Server_TestFunc5() function Zend_Soap_Server_TestFunc6() { return "string"; -} \ No newline at end of file +} From daba97f14aeef31afc9f64d3bcc28c3211c7c783 Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 21 Jul 2009 20:24:35 +0000 Subject: [PATCH 011/123] [TESTS] Scrubbed test suite to ensure it can run with or without output buffering, and so that no tests fail when run as a full suite git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16933 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/AutoDiscoverTest.php | 43 ++++++++++++--------------------------- test/ServerTest.php | 3 +-- test/WsdlTest.php | 5 ++--- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 3f2633f8..35410aef 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -59,7 +59,6 @@ function testSetClass() ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); - ob_end_clean(); $wsdl = '' . 'handle(); $dom->loadXML(ob_get_clean()); - ob_end_clean(); $wsdl = '' . 'handle(); $dom->loadXML(ob_get_clean()); - ob_end_clean(); $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); @@ -331,10 +328,9 @@ function testAddFunctionSimple() $dom = new DOMDocument(); ob_start(); $server->handle(); - $dom->loadXML(ob_get_contents()); + $dom->loadXML(ob_get_clean()); $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); - ob_end_clean(); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -377,10 +373,9 @@ function testAddFunctionSimpleWithDifferentStyle() $dom = new DOMDocument(); ob_start(); $server->handle(); - $dom->loadXML(ob_get_contents()); + $dom->loadXML(ob_get_clean()); $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); - ob_end_clean(); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -429,10 +424,9 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $dom = new DOMDocument(); ob_start(); $server->handle(); - $dom->loadXML(ob_get_contents()); + $dom->loadXML(ob_get_clean()); $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); - ob_end_clean(); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -461,11 +455,9 @@ function testAddFunctionMultiple() $dom = new DOMDocument(); ob_start(); $server->handle(); - $dom->loadXML(ob_get_contents()); + $dom->loadXML(ob_get_clean()); $dom->save(dirname(__FILE__).'/_files/addfunction2.wsdl'); - ob_end_clean(); - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -567,8 +559,7 @@ public function testUseHttpsSchemaIfAccessedThroughHttps() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertContains($httpsScriptUri, $wsdlOutput); } @@ -585,8 +576,7 @@ public function testChangeWsdlUriInConstructor() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertContains("http://example.com/service.php", $wsdlOutput); @@ -605,8 +595,7 @@ public function testChangeWsdlUriViaSetUri() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertContains("http://example.com/service.php", $wsdlOutput); @@ -636,8 +625,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertContains("http://example.com/service.php", $wsdlOutput); @@ -646,8 +634,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertNotContains("http://example.com/service.php", $wsdlOutput); @@ -668,8 +655,7 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertEquals(1, substr_count($wsdlOutput, '')); $this->assertEquals(1, substr_count($wsdlOutput, '')); @@ -757,8 +743,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertEquals(1, substr_count($wsdlOutput, 'wsdl:arrayType="tns:Zend_Soap_AutoDiscoverTestClass1[]"'), @@ -788,8 +773,7 @@ public function testDumpOrXmlOfAutoDiscover() ob_start(); $server->handle(); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertEquals( $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), @@ -798,8 +782,7 @@ public function testDumpOrXmlOfAutoDiscover() ob_start(); $server->dump(false); - $wsdlOutput = ob_get_contents(); - ob_end_clean(); + $wsdlOutput = ob_get_clean(); $this->assertEquals( $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), diff --git a/test/ServerTest.php b/test/ServerTest.php index f6dbf0fc..7bc1977d 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -905,8 +905,7 @@ function __construct(Zend_Soap_Server $server, $wsdl, $options) { function __doRequest($request, $location, $action, $version) { ob_start(); $this->server->handle($request); - $response = ob_get_contents(); - ob_end_clean(); + $response = ob_get_clean(); return $response; } diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 29d76f67..7b64ff62 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -464,8 +464,7 @@ function testDump() ob_start(); $wsdl->dump(); - $wsdlDump = ob_get_contents(); - ob_end_clean(); + $wsdlDump = ob_get_clean(); $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdlDump), '' . @@ -676,4 +675,4 @@ class Zend_Soap_Wsdl_Test { * @var string */ public $var2; -} \ No newline at end of file +} From d1a33db61d790980a0a8a99488cd05221f2c4cd5 Mon Sep 17 00:00:00 2001 From: beberlei Date: Tue, 21 Jul 2009 21:54:33 +0000 Subject: [PATCH 012/123] ZF-6742 - Applied patch by Fabien Crespel which implements support for Objcets and Arrays of Objects in ArrayOfTypeSequence WSDL generation strategy git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16935 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/ArrayOfTypeSequence.php | 27 ++++----- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 55 ++++++++++++------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php index c3bf65be..4cf581d6 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -19,9 +19,9 @@ * @version $Id$ */ -require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; +require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; -class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_Abstract +class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_DefaultComplexType { /** * Add an unbounded ArrayOfType based on the xsd:sequence syntax if type[] is detected in return value doc comment. @@ -37,7 +37,7 @@ public function addComplexType($type) $singularType = $this->_getSingularType($type); for($i = 1; $i <= $nestedCounter; $i++) { - $complexTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i); + $complexTypeName = substr($this->_getTypeNameBasedOnNestingLevel($singularType, $i), 4); $childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1); $this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName); @@ -46,11 +46,12 @@ public function addComplexType($type) $this->getContext()->addType($complexTypeName); return "tns:$complexTypeName"; + } else if (!in_array($type, $this->getContext()->getTypes())) { + // New singular complex type + return parent::addComplexType($type); } else { - require_once "Zend/Soap/Wsdl/Exception.php"; - throw new Zend_Soap_Wsdl_Exception(sprintf( - 'ArrayOfTypeSequence Strategy does not allow for complex types that are not in @return type[] syntax. "%s" type was specified.', $type - )); + // Existing complex type + return $this->getContext()->getType($type); } } @@ -70,7 +71,7 @@ protected function _getTypeNameBasedOnNestingLevel($singularType, $level) $prefix = str_repeat("ArrayOf", $level); $xsdType = $this->_getStrippedXsdType($singularType); $arrayType = $prefix.$xsdType; - return $arrayType; + return "tns:$arrayType"; } } @@ -95,14 +96,6 @@ protected function _getStrippedXsdType($singularType) protected function _getSingularType($type) { $singulartype = $this->getContext()->getType(str_replace("[]", "", $type)); - - if(substr($singulartype, 0, 4) != "xsd:") { - require_once "Zend/Soap/Wsdl/Exception.php"; - throw new Zend_Soap_Wsdl_Exception(sprintf( - 'ArrayOfTypeSequence Strategy works only with arrays of simple types like int, string, boolean, not with "%s".'. - 'You may use Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex for more complex types.', $type - )); - } return $singulartype; } @@ -147,4 +140,4 @@ protected function _addElementFromWsdlAndChildTypes($arrayType, $childTypeName) $this->getContext()->addType($arrayType); } } -} \ No newline at end of file +} diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index ec23c26e..fd588605 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -78,7 +78,7 @@ public function testFunctionReturningNestedArrayOfString() // Check for ArrayOfArrayOfString $this->assertContains( - '', + '', $wsdl ); // Check for ArrayOfString @@ -97,12 +97,12 @@ public function testFunctionReturningMultipleNestedArrayOfType() // Check for ArrayOfArrayOfArrayOfString $this->assertContains( - '', + '', $wsdl ); // Check for ArrayOfArrayOfString $this->assertContains( - '', + '', $wsdl ); // Check for ArrayOfString @@ -112,33 +112,46 @@ public function testFunctionReturningMultipleNestedArrayOfType() ); } - public function testSpecifyingNonSimpleArrayTypeThrowsException() + + public function testAddComplexTypeObject() { - try { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest[]'); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest'); + + $this->assertEquals("tns:Zend_Soap_Wsdl_SequenceTest", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); } - public function testStrategyCannotHandleReturnOfObjectsThrowingException() + public function testAddComplexTypeArrayOfObject() { - try { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest'); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } + + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest[]'); + + $this->assertEquals("tns:ArrayOfZend_soap_wsdl_sequencetest", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); } public function testAddComplexTypeOfNonExistingClassThrowsException() { - try { - $this->wsdl->addComplexType('Zend_Soap_Wsdl_UnknownClass[]'); - } catch(Zend_Soap_Wsdl_Exception $e) { + $this->setExpectedException("Zend_Soap_Wsdl_Exception"); - } + $this->wsdl->addComplexType('Zend_Soap_Wsdl_UnknownClass[]'); } } From 29591bfeeac33dd187d062bab6ba1a61a8ae431c Mon Sep 17 00:00:00 2001 From: mikaelkael Date: Wed, 22 Jul 2009 18:05:45 +0000 Subject: [PATCH 013/123] ZF-7335: add svn:keyword Id for all files without it git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16971 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client/Exception.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/Exception.php b/src/Client/Exception.php index 33e79d7b..f29a4f53 100644 --- a/src/Client/Exception.php +++ b/src/Client/Exception.php @@ -28,7 +28,7 @@ * @subpackage Client * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $ + * @version $Id$ */ class Zend_Soap_Client_Exception extends Zend_Exception {} From cd1e380cd212293716bad71a9036a0655a11a029 Mon Sep 17 00:00:00 2001 From: matthew Date: Thu, 23 Jul 2009 20:19:23 +0000 Subject: [PATCH 014/123] [TESTS] Fixed two PHP 5.3 issues in test suite git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17006 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/ServerTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/ServerTest.php b/test/ServerTest.php index 7bc1977d..c240e98b 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -882,7 +882,8 @@ public function testSetAndGetWsdlCache() if (extension_loaded('soap')) { /** Local SOAP client */ -class Zend_Soap_Server_TestLocalSoapClient extends SoapClient { +class Zend_Soap_Server_TestLocalSoapClient extends SoapClient +{ /** * Server object * @@ -897,12 +898,14 @@ class Zend_Soap_Server_TestLocalSoapClient extends SoapClient { * @param string $wsdl * @param array $options */ - function __construct(Zend_Soap_Server $server, $wsdl, $options) { + function __construct(Zend_Soap_Server $server, $wsdl, $options) + { $this->server = $server; parent::__construct($wsdl, $options); } - function __doRequest($request, $location, $action, $version) { + function __doRequest($request, $location, $action, $version, $one_way = 0) + { ob_start(); $this->server->handle($request); $response = ob_get_clean(); From 0aad3e321475f7765b80611392a59bbdfdbece90 Mon Sep 17 00:00:00 2001 From: mikaelkael Date: Mon, 10 Aug 2009 22:51:26 +0000 Subject: [PATCH 015/123] [ZF-7315] Review phpDoc for API documentation generation git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17539 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 18 +++++++++++++++++- src/AutoDiscover/Exception.php | 3 +++ src/Server.php | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index d0b6072b..8f3add5b 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -20,10 +20,25 @@ * @version $Id$ */ +/** + * @see Zend_Server_Interface + */ require_once 'Zend/Server/Interface.php'; +/** + * @see Zend_Soap_Wsdl + */ require_once 'Zend/Soap/Wsdl.php'; +/** + * @see Zend_Server_Reflection + */ require_once 'Zend/Server/Reflection.php'; +/** + * @see Zend_Server_Abstract + */ require_once 'Zend/Server/Abstract.php'; +/** + * @see Zend_Uri + */ require_once 'Zend/Uri.php'; /** @@ -33,7 +48,8 @@ * @package Zend_Soap * @subpackage AutoDiscover */ -class Zend_Soap_AutoDiscover implements Zend_Server_Interface { +class Zend_Soap_AutoDiscover implements Zend_Server_Interface +{ /** * @var Zend_Soap_Wsdl */ diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php index 010c4a3e..f0600e88 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/AutoDiscover/Exception.php @@ -20,6 +20,9 @@ * @version $Id$ */ +/** + * @see Zend_Exception + */ require_once "Zend/Exception.php"; /** diff --git a/src/Server.php b/src/Server.php index 9a1f2abd..9cb089ea 100644 --- a/src/Server.php +++ b/src/Server.php @@ -82,7 +82,7 @@ class Zend_Soap_Server implements Zend_Server_Interface /** * WSDL Caching Options of SOAP Server * - * @var + * @var mixed */ protected $_wsdlCache; From 4f2045d6c0b6b5fe567a601d53d5550b6991f79e Mon Sep 17 00:00:00 2001 From: mikaelkael Date: Tue, 11 Aug 2009 21:03:55 +0000 Subject: [PATCH 016/123] [ZF-7315] Review phpDoc for API documentation generation git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17558 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl.php | 7 +++++++ src/Wsdl/Exception.php | 12 ++++++++++++ src/Wsdl/Strategy/Abstract.php | 3 +++ src/Wsdl/Strategy/AnyType.php | 12 ++++++++++++ src/Wsdl/Strategy/ArrayOfTypeComplex.php | 12 ++++++++++++ src/Wsdl/Strategy/ArrayOfTypeSequence.php | 12 ++++++++++++ src/Wsdl/Strategy/Composite.php | 12 ++++++++++++ src/Wsdl/Strategy/DefaultComplexType.php | 12 ++++++++++++ src/Wsdl/Strategy/Interface.php | 10 +++++++++- 9 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/Wsdl.php b/src/Wsdl.php index 014c0470..c14659b0 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -19,7 +19,14 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; + +/** + * @see Zend_Soap_Wsdl_Strategy_Abstract + */ require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; /** diff --git a/src/Wsdl/Exception.php b/src/Wsdl/Exception.php index 804dd5b5..2d584829 100644 --- a/src/Wsdl/Exception.php +++ b/src/Wsdl/Exception.php @@ -20,6 +20,18 @@ * @version $Id$ */ +/** + * @see Zend_Exception + */ require_once "Zend/Exception.php"; +/** + * Zend_Soap_Wsdl_Exception + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Soap_Wsdl_Exception extends Zend_Exception { } \ No newline at end of file diff --git a/src/Wsdl/Strategy/Abstract.php b/src/Wsdl/Strategy/Abstract.php index d2e05feb..d7844560 100644 --- a/src/Wsdl/Strategy/Abstract.php +++ b/src/Wsdl/Strategy/Abstract.php @@ -20,6 +20,9 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; /** diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php index 3c89dab7..73fc1e24 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -20,8 +20,20 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; +/** + * Zend_Soap_Wsdl_Strategy_AnyType + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface { /** diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php index 3253fe91..342a0e73 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -20,8 +20,20 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_DefaultComplexType + */ require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; +/** + * Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_DefaultComplexType { protected $_inProcess = array(); diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php index 4cf581d6..71a10e22 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -19,8 +19,20 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_DefaultComplexType + */ require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; +/** + * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_DefaultComplexType { /** diff --git a/src/Wsdl/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php index 6e3f9a3b..4b063e04 100644 --- a/src/Wsdl/Strategy/Composite.php +++ b/src/Wsdl/Strategy/Composite.php @@ -20,8 +20,20 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_Interface + */ require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; +/** + * Zend_Soap_Wsdl_Strategy_Composite + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface { /** diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index b7c9196b..65fb382a 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -20,8 +20,20 @@ * @version $Id$ */ +/** + * @see Zend_Soap_Wsdl_Strategy_Abstract + */ require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; +/** + * Zend_Soap_Wsdl_Strategy_DefaultComplexType + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract { /** diff --git a/src/Wsdl/Strategy/Interface.php b/src/Wsdl/Strategy/Interface.php index 7175f169..8b399ea1 100644 --- a/src/Wsdl/Strategy/Interface.php +++ b/src/Wsdl/Strategy/Interface.php @@ -20,7 +20,15 @@ * @version $Id$ */ - +/** + * Interface for Zend_Soap_Wsdl_Strategy. + * + * @category Zend + * @package Zend_Soap + * @subpackage Wsdl + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ interface Zend_Soap_Wsdl_Strategy_Interface { /** From b8e074402153e6488b21d4622032ab21410356eb Mon Sep 17 00:00:00 2001 From: alexander Date: Thu, 13 Aug 2009 18:01:41 +0000 Subject: [PATCH 017/123] Merge cs-17363 back to trunk. [ZF-7581] related. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17573 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/AllTests.php | 28 +++++ test/AutoDiscover/OnlineTest.php | 32 ++++- test/AutoDiscoverTest.php | 24 +++- test/ClientTest.php | 13 +- test/ServerTest.php | 10 +- test/Wsdl/AllTests.php | 31 ++++- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 11 +- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 11 +- test/Wsdl/CompositeStrategyTest.php | 11 +- test/Wsdl/DefaultComplexTypeTest.php | 31 ++++- test/Wsdl/ElementTest.php | 31 ++++- test/Wsdl/ParserTest.php | 31 ++++- test/WsdlTest.php | 25 +++- test/_files/commontypes.php | 114 +++++++++++++++++- test/_files/fulltests/server1.php | 44 ++++++- test/_files/fulltests/server2.php | 36 +++++- 16 files changed, 453 insertions(+), 30 deletions(-) diff --git a/test/AllTests.php b/test/AllTests.php index 8d54a4a9..5a51e513 100644 --- a/test/AllTests.php +++ b/test/AllTests.php @@ -1,4 +1,24 @@ assertEquals("test", $ret->foo); $this->assertEquals("test", $ret->bar); } -} \ No newline at end of file +} diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 35410aef..8d7e3810 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -1,7 +1,23 @@ assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itsself.", $e->getMessage()); } } -} \ No newline at end of file +} diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index fd588605..3e298405 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -34,6 +34,15 @@ require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php'; +/** + * @category Zend + * @package Zend_Soap + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Soap + * @group Zend_Soap_Wsdl + */ class Zend_Soap_Wsdl_ArrayOfTypeSequenceStrategyTest extends PHPUnit_Framework_TestCase { private $wsdl; @@ -161,4 +170,4 @@ class Zend_Soap_Wsdl_SequenceTest * @var int */ public $var = 5; -} \ No newline at end of file +} diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php index 1f7dccc9..40e26128 100644 --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -36,6 +36,15 @@ require_once 'Zend/Soap/Wsdl/Strategy/DefaultComplexType.php'; require_once 'Zend/Soap/Wsdl/Strategy/Composite.php'; +/** + * @category Zend + * @package Zend_Soap + * @subpackage UnitTests + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @group Zend_Soap + * @group Zend_Soap_Wsdl + */ class Zend_Soap_Wsdl_CompositeStrategyTest extends PHPUnit_Framework_TestCase { public function testCompositeApiAddingStragiesToTypes() @@ -136,4 +145,4 @@ class Zend_Soap_Wsdl_Cookie } class Zend_Soap_Wsdl_Anything { -} \ No newline at end of file +} diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index dad4cb27..967c4bb4 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -1,10 +1,39 @@ assertTrue( in_array($name, $collection->getElementNames()) ); } } -} \ No newline at end of file +} diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php index e24511ee..b9fcf60d 100644 --- a/test/Wsdl/ParserTest.php +++ b/test/Wsdl/ParserTest.php @@ -1,10 +1,39 @@ parse(); } -} \ No newline at end of file +} diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 7b64ff62..203e6b33 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -1,7 +1,23 @@ setClass('Zend_Soap_Service_Server1'); -$server->handle(); \ No newline at end of file +$server->handle(); diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index 5aa7987f..31a04a01 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -1,9 +1,36 @@ setClass('Zend_Soap_Service_Server2'); -$server->handle(); \ No newline at end of file +$server->handle(); From c02cdadf693c5e6004ccf24e67a8aa00e17f5fd7 Mon Sep 17 00:00:00 2001 From: mikaelkael Date: Tue, 18 Aug 2009 21:40:09 +0000 Subject: [PATCH 018/123] ZF-7335 : TESTS - add missing svn:keywords git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17667 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/Wsdl/AllTests.php | 2 +- test/_files/commontypes.php | 2 +- test/_files/fulltests/server1.php | 2 +- test/_files/fulltests/server2.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Wsdl/AllTests.php b/test/Wsdl/AllTests.php index e3523e0f..61b222d9 100644 --- a/test/Wsdl/AllTests.php +++ b/test/Wsdl/AllTests.php @@ -17,7 +17,7 @@ * @subpackage UnitTests * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: AllTests.php 16225 2009-06-21 20:34:55Z thomas $ + * @version $Id$ */ require_once dirname(__FILE__)."/../../../TestHelper.php"; diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index 6d024f8e..b14e8bcd 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -17,7 +17,7 @@ * @subpackage UnitTests * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ + * @version $Id$ */ /* Test Functions */ diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php index 13a858e7..cc10b773 100644 --- a/test/_files/fulltests/server1.php +++ b/test/_files/fulltests/server1.php @@ -17,7 +17,7 @@ * @subpackage UnitTests * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ + * @version $Id$ */ require_once "Zend/Soap/AutoDiscover.php"; diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index 31a04a01..680ae5c5 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -17,7 +17,7 @@ * @subpackage UnitTests * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: $ + * @version $Id$ */ require_once "Zend/Soap/AutoDiscover.php"; From 160e41c647d174b7a39bed9f04002ff60d2fd5ee Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 20 Aug 2009 12:55:34 +0000 Subject: [PATCH 019/123] [ZF-7316] Code cleaning: - reverted CRLF (Win*) to LF (*nix) - reverted TABS to 4 spaces - erased ending spaces used revision 17680 git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17687 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client.php | 14 +++++++------- src/Client/DotNet.php | 12 ++++++------ src/Server.php | 2 +- src/Server/Exception.php | 2 +- src/Wsdl.php | 12 ++++++------ src/Wsdl/Strategy/AnyType.php | 2 +- src/Wsdl/Strategy/Interface.php | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Client.php b/src/Client.php index c717d8f8..38b89bf3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1010,13 +1010,13 @@ protected function _preProcessResult($result) */ public function addSoapInputHeader(SoapHeader $header, $permanent = false) { - if ($permanent) { - $this->_permanentSoapInputHeaders[] = $header; - } else { - $this->_soapInputHeaders[] = $header; - } + if ($permanent) { + $this->_permanentSoapInputHeaders[] = $header; + } else { + $this->_soapInputHeaders[] = $header; + } - return $this; + return $this; } /** @@ -1039,7 +1039,7 @@ public function resetSoapInputHeaders() */ public function getLastSoapOutputHeaderObjects() { - return $this->_soapOutputHeaders; + return $this->_soapOutputHeaders; } /** diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 405f5d31..a6aeb3eb 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -65,12 +65,12 @@ public function __construct($wsdl = null, $options = null) */ protected function _preProcessArguments($arguments) { - if (count($arguments) > 1 || - (count($arguments) == 1 && !is_array(reset($arguments))) - ) { - require_once 'Zend/Soap/Client/Exception.php'; - throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); - } + if (count($arguments) > 1 || + (count($arguments) == 1 && !is_array(reset($arguments))) + ) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); + } // Do nothing return array($arguments); diff --git a/src/Server.php b/src/Server.php index 9cb089ea..8933bad9 100644 --- a/src/Server.php +++ b/src/Server.php @@ -463,7 +463,7 @@ public function setSoapFeatures($feature) /** * Return current SOAP Features options - * + * * @return int */ public function getSoapFeatures() diff --git a/src/Server/Exception.php b/src/Server/Exception.php index 86bffddd..db1e5eda 100644 --- a/src/Server/Exception.php +++ b/src/Server/Exception.php @@ -17,7 +17,7 @@ * @subpackage Server * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - */ + */ /** Zend_Exception */ diff --git a/src/Wsdl.php b/src/Wsdl.php index c14659b0..b8df7d60 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -602,10 +602,10 @@ public function addComplexType($type) // delegates the detection of a complex type to the current strategy return $strategy->addComplexType($type); } - + /** * Parse an xsd:element represented as an array into a DOMElement. - * + * * @param array $element an xsd:element represented as an array * @return DOMElement parsed element */ @@ -615,7 +615,7 @@ private function _parseElement($element) require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception("The 'element' parameter needs to be an associative array."); } - + $elementXml = $this->_dom->createElement('xsd:element'); foreach ($element as $key => $value) { if (in_array($key, array('sequence', 'all', 'choice'))) { @@ -637,10 +637,10 @@ private function _parseElement($element) } return $elementXml; } - + /** * Add an xsd:element represented as an array to the schema. - * + * * Array keys represent attribute names and values their respective value. * The 'sequence', 'all' and 'choice' keys must have an array of elements as their value, * to add them to a nested complexType. @@ -652,7 +652,7 @@ private function _parseElement($element) * * * - * + * * @param array $element an xsd:element represented as an array * @return string xsd:element for the given element array */ diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php index 73fc1e24..23c4d1f2 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -43,7 +43,7 @@ class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interfa */ public function setContext(Zend_Soap_Wsdl $context) { - + } /** diff --git a/src/Wsdl/Strategy/Interface.php b/src/Wsdl/Strategy/Interface.php index 8b399ea1..6927c81a 100644 --- a/src/Wsdl/Strategy/Interface.php +++ b/src/Wsdl/Strategy/Interface.php @@ -33,7 +33,7 @@ interface Zend_Soap_Wsdl_Strategy_Interface { /** * Method accepts the current WSDL context file. - * + * * @param $context */ public function setContext(Zend_Soap_Wsdl $context); From 062fd4ff45752cda1009ed2df374ace840414822 Mon Sep 17 00:00:00 2001 From: beberlei Date: Wed, 9 Sep 2009 17:05:43 +0000 Subject: [PATCH 020/123] ZF-7810 - Convert private to protected method in Zend_Soap_Server git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18043 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server.php b/src/Server.php index 8933bad9..c9472a83 100644 --- a/src/Server.php +++ b/src/Server.php @@ -675,7 +675,7 @@ public function getPersistence() * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request * @return Zend_Soap_Server */ - private function _setRequest($request) + protected function _setRequest($request) { if ($request instanceof DOMDocument) { $xml = $request->saveXML(); From ccf3bebe25d6305595e44419a0db61d1b1cdb68e Mon Sep 17 00:00:00 2001 From: beberlei Date: Wed, 9 Sep 2009 17:38:18 +0000 Subject: [PATCH 021/123] ZF-7802 - Fix wrong docblock on Zend_Soap_Server::setClass git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18046 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Server.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Server.php b/src/Server.php index c9472a83..21c5a136 100644 --- a/src/Server.php +++ b/src/Server.php @@ -539,16 +539,14 @@ public function addFunction($function, $namespace = '') * Accepts a class name to use when handling requests. Any additional * arguments will be passed to that class' constructor when instantiated. * - * @param mixed $class Class name or object instance to examine and attach - * to the server. - * @param mixed $arg1 Optional argument to pass to class constructor - * @param mixed $arg2 Optional second argument to pass to class constructor - * dispatch. + * See {@link setObject()} to set preconfigured object instances as request handlers. + * + * @param string $class Class Name which executes SOAP Requests at endpoint. * @return Zend_Soap_Server * @throws Zend_Soap_Server_Exception if called more than once, or if class * does not exist */ - public function setClass($class, $arg1 = null, $arg2 = null) + public function setClass($class) { if (isset($this->_class)) { require_once 'Zend/Soap/Server/Exception.php'; From 2f9afa5174c78315e7a4c05ce8124c016297c8be Mon Sep 17 00:00:00 2001 From: beberlei Date: Wed, 9 Sep 2009 18:21:00 +0000 Subject: [PATCH 022/123] ZF-7802 - Fixed introduced regression in r18046 by again adding uncesseary parameters on Zend_Soap_Server::setClass() git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18048 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server.php b/src/Server.php index 21c5a136..bb18c39b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -546,7 +546,7 @@ public function addFunction($function, $namespace = '') * @throws Zend_Soap_Server_Exception if called more than once, or if class * does not exist */ - public function setClass($class) + public function setClass($class, $namespace = '', $argv = null) { if (isset($this->_class)) { require_once 'Zend/Soap/Server/Exception.php'; From aaa8dc2a9df565dcc1c1722b6e0d7877d86cb9e7 Mon Sep 17 00:00:00 2001 From: sgehrig Date: Fri, 18 Sep 2009 14:19:55 +0000 Subject: [PATCH 023/123] ZF-7084 removed array()-warp from arguments parameter git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18235 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client/DotNet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index a6aeb3eb..6c2a4801 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -73,7 +73,7 @@ protected function _preProcessArguments($arguments) } // Do nothing - return array($arguments); + return $arguments; } /** From 718f163b41207dc3a2e6b2032580ee0384737c47 Mon Sep 17 00:00:00 2001 From: sgehrig Date: Fri, 16 Oct 2009 12:36:12 +0000 Subject: [PATCH 024/123] ZF-8053 added user_agent-option git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18569 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client.php | 27 +++++++++++++++++++++++++++ test/ClientTest.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/Client.php b/src/Client.php index 38b89bf3..586230c1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -82,6 +82,7 @@ class Zend_Soap_Client protected $_stream_context = null; protected $_features = null; protected $_cache_wsdl = null; + protected $_user_agent = null; /** * WSDL used to access server @@ -256,6 +257,11 @@ public function setOptions($options) case 'cache_wsdl': $this->setWsdlCache($value); break; + case 'useragent': + case 'userAgent': + case 'user_agent': + $this->setUserAgent($value); + break; // Not used now // case 'connection_timeout': @@ -302,6 +308,7 @@ public function getOptions() $options['stream_context'] = $this->getStreamContext(); $options['cache_wsdl'] = $this->getWsdlCache(); $options['features'] = $this->getSoapFeatures(); + $options['user_agent'] = $this->getUserAgent(); foreach ($options as $key => $value) { if ($value == null) { @@ -850,6 +857,26 @@ public function getWsdlCache() return $this->_cache_wsdl; } + /** + * Set the string to use in User-Agent header + * + * @param string $userAgent + * @return Zend_Soap_Client + */ + public function setUserAgent($userAgent) + { + $this->_user_agent = (string)$userAgent; + return $this; + } + + /** + * Get current string to use in User-Agent header + */ + public function getUserAgent() + { + return $this->_user_agent; + } + /** * Retrieve request XML * diff --git a/test/ClientTest.php b/test/ClientTest.php index f73da6ad..369b1705 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -172,6 +172,36 @@ public function testGetOptions() $this->assertTrue($client->getOptions() == $options); } + /** + * @group ZF-8053 + */ + public function testGetAndSetUserAgentOption() + { + $client = new Zend_Soap_Client(); + $this->assertNull($client->getUserAgent()); + + $client->setUserAgent('agent1'); + $this->assertEquals('agent1', $client->getUserAgent()); + + $client->setOptions(array( + 'user_agent' => 'agent2' + )); + $this->assertEquals('agent2', $client->getUserAgent()); + + $client->setOptions(array( + 'useragent' => 'agent3' + )); + $this->assertEquals('agent3', $client->getUserAgent()); + + $client->setOptions(array( + 'userAgent' => 'agent4' + )); + $this->assertEquals('agent4', $client->getUserAgent()); + + $options = $client->getOptions(); + $this->assertEquals('agent4', $options['user_agent']); + } + public function testGetFunctions() { $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); From 7b71f0419b108d7fb947e150461159a0e718b410 Mon Sep 17 00:00:00 2001 From: "yoshida@zend.co.jp" Date: Sat, 7 Nov 2009 02:47:26 +0000 Subject: [PATCH 025/123] [ZF-8244] add PHP_URL_SCHEME to parse_url() in validateUrn() of Zend_Soap_Client and Zend_Soap_Server git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18888 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client.php | 23 +++++++++++++++-------- src/Server.php | 10 +++++----- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Client.php b/src/Client.php index 586230c1..a38883aa 100644 --- a/src/Client.php +++ b/src/Client.php @@ -20,13 +20,19 @@ * @version $Id$ */ -/** Zend_Soap_Server */ +/** + * @see Zend_Soap_Server + */ require_once 'Zend/Soap/Server.php'; -/** Zend_Soap_Client_Local */ +/** + * @see Zend_Soap_Client_Local + */ require_once 'Zend/Soap/Client/Local.php'; -/** Zend_Soap_Client_Common */ +/** + * @see Zend_Soap_Client_Common + */ require_once 'Zend/Soap/Client/Common.php'; /** @@ -422,13 +428,14 @@ public function getEncoding() */ public function validateUrn($urn) { - $segs = parse_url($urn); - if (isset($segs['scheme'])) { - return true; + $scheme = parse_url($urn, PHP_URL_SCHEME); + if ($scheme === false || $scheme === null) { + require_once 'Zend/Soap/Client/Exception.php'; + throw new Zend_Soap_Client_Exception('Invalid URN'); } - require_once 'Zend/Soap/Client/Exception.php'; - throw new Zend_Soap_Client_Exception('Invalid URN'); + return true; + } /** diff --git a/src/Server.php b/src/Server.php index bb18c39b..22db1271 100644 --- a/src/Server.php +++ b/src/Server.php @@ -327,13 +327,13 @@ public function getSoapVersion() */ public function validateUrn($urn) { - $segs = parse_url($urn); - if (isset($segs['scheme'])) { - return true; + $scheme = parse_url($urn, PHP_URL_SCHEME); + if ($scheme === false || $scheme === null) { + require_once 'Zend/Soap/Server/Exception.php'; + throw new Zend_Soap_Server_Exception('Invalid URN'); } - require_once 'Zend/Soap/Server/Exception.php'; - throw new Zend_Soap_Server_Exception('Invalid URN'); + return true; } /** From 6875a7a7f3e835c0952bd11222fb78ad886e0e81 Mon Sep 17 00:00:00 2001 From: alexander Date: Thu, 12 Nov 2009 15:37:56 +0000 Subject: [PATCH 026/123] Remove trailing whitespaces, change tab for spaces, convert CRLF to LF. ZF-7316 related. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18950 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/AutoDiscover/OnlineTest.php | 2 +- test/AutoDiscoverTest.php | 10 +- test/ClientTest.php | 92 ++++++------- test/ServerTest.php | 124 +++++++++--------- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 2 +- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 2 +- test/Wsdl/ElementTest.php | 6 +- test/Wsdl/ParserTest.php | 2 +- test/WsdlTest.php | 2 +- test/_files/commontypes.php | 30 ++--- 10 files changed, 136 insertions(+), 136 deletions(-) diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index 4771825c..3336a407 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -19,7 +19,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ - + require_once dirname(__FILE__)."/../../../TestHelper.php"; require_once dirname(__FILE__)."/../_files/commontypes.php"; diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 8d7e3810..518a9db1 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -72,7 +72,7 @@ protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) function testSetClass() { $scriptUri = 'http://localhost/my_script.php'; - + $server = new Zend_Soap_AutoDiscover(); $server->setClass('Zend_Soap_AutoDiscover_Test'); $dom = new DOMDocument(); @@ -198,7 +198,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -213,7 +213,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -561,7 +561,7 @@ function testAddFunctionMultiple() $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - + unlink(dirname(__FILE__).'/_files/addfunction2.wsdl'); } @@ -688,7 +688,7 @@ public function testUnusedFunctionsOfAutoDiscoverThrowException() $server->setPersistence("bogus"); $this->fail(); } catch(Zend_Soap_AutoDiscover_Exception $e) { - + } try { diff --git a/test/ClientTest.php b/test/ClientTest.php index 369b1705..d1fc1b3f 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -67,43 +67,43 @@ public function setUp() public function testSetOptions() { - /************************************************************* - * ------ Test WSDL mode options ----------------------------- - *************************************************************/ - $client = new Zend_Soap_Client(); + /************************************************************* + * ------ Test WSDL mode options ----------------------------- + *************************************************************/ + $client = new Zend_Soap_Client(); - $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); + $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); $ctx = stream_context_create(); - $nonWsdlOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), - 'encoding' => 'ISO-8859-1', - 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'use' => SOAP_ENCODED, - 'style' => SOAP_RPC, + $nonWsdlOptions = array('soap_version' => SOAP_1_1, + 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', + 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'use' => SOAP_ENCODED, + 'style' => SOAP_RPC, - 'login' => 'http_login', - 'password' => 'http_password', + 'login' => 'http_login', + 'password' => 'http_password', - 'proxy_host' => 'proxy.somehost.com', - 'proxy_port' => 8080, - 'proxy_login' => 'proxy_login', - 'proxy_password' => 'proxy_password', + 'proxy_host' => 'proxy.somehost.com', + 'proxy_port' => 8080, + 'proxy_login' => 'proxy_login', + 'proxy_password' => 'proxy_password', - 'local_cert' => dirname(__FILE__).'/_files/cert_file', - 'passphrase' => 'some pass phrase', + 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'passphrase' => 'some pass phrase', 'stream_context' => $ctx, 'cache_wsdl' => 8, 'features' => 4, - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); - $client->setOptions($nonWsdlOptions); - $this->assertTrue($client->getOptions() == $nonWsdlOptions); + $client->setOptions($nonWsdlOptions); + $this->assertTrue($client->getOptions() == $nonWsdlOptions); /************************************************************* @@ -140,7 +140,7 @@ public function testSetOptions() public function testGetOptions() { - $client = new Zend_Soap_Client(); + $client = new Zend_Soap_Client(); $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); @@ -220,7 +220,7 @@ public function testGetFunctions() */ public function testGetTypes() { - // Remove the following line when you implement this test. + // Remove the following line when you implement this test. $this->markTestIncomplete( "This test has not been implemented yet." ); @@ -233,7 +233,7 @@ public function testGetLastRequest() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); @@ -263,7 +263,7 @@ public function testGetLastResponse() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); @@ -294,7 +294,7 @@ public function testCallInvoke() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); @@ -306,29 +306,29 @@ public function testSetOptionsWithZendConfig() { $ctx = stream_context_create(); - $nonWsdlOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), - 'encoding' => 'ISO-8859-1', - 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'use' => SOAP_ENCODED, - 'style' => SOAP_RPC, + $nonWsdlOptions = array('soap_version' => SOAP_1_1, + 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', + 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'encoding' => 'ISO-8859-1', + 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', + 'use' => SOAP_ENCODED, + 'style' => SOAP_RPC, - 'login' => 'http_login', - 'password' => 'http_password', + 'login' => 'http_login', + 'password' => 'http_password', - 'proxy_host' => 'proxy.somehost.com', - 'proxy_port' => 8080, - 'proxy_login' => 'proxy_login', - 'proxy_password' => 'proxy_password', + 'proxy_host' => 'proxy.somehost.com', + 'proxy_port' => 8080, + 'proxy_login' => 'proxy_login', + 'proxy_password' => 'proxy_password', - 'local_cert' => dirname(__FILE__).'/_files/cert_file', - 'passphrase' => 'some pass phrase', + 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'passphrase' => 'some pass phrase', 'stream_context' => $ctx, - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5 + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5 ); $config = new Zend_Config($nonWsdlOptions); diff --git a/test/ServerTest.php b/test/ServerTest.php index 791feb5b..5046b7c7 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -98,7 +98,7 @@ public function testSetWsdlViaOptionsArrayIsPossible() public function testGetOptions() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); @@ -112,7 +112,7 @@ public function testGetOptions() public function testEncoding() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getEncoding()); $server->setEncoding('ISO-8859-1'); @@ -128,7 +128,7 @@ public function testEncoding() public function testSoapVersion() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertEquals(SOAP_1_2, $server->getSoapVersion()); $server->setSoapVersion(SOAP_1_1); @@ -143,7 +143,7 @@ public function testSoapVersion() public function testValidateUrn() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); try { $server->validateUrn('bogosity'); @@ -158,7 +158,7 @@ public function testValidateUrn() public function testSetActor() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); @@ -173,7 +173,7 @@ public function testSetActor() public function testGetActor() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); @@ -182,7 +182,7 @@ public function testGetActor() public function testSetUri() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); @@ -197,7 +197,7 @@ public function testSetUri() public function testGetUri() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); @@ -206,7 +206,7 @@ public function testGetUri() public function testSetClassmap() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', 'TestData2' => 'Zend_Soap_Server_TestData2'); @@ -230,7 +230,7 @@ public function testSetClassmap() public function testGetClassmap() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', 'TestData2' => 'Zend_Soap_Server_TestData2'); @@ -242,7 +242,7 @@ public function testGetClassmap() public function testSetWsdl() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getWsdl()); $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); @@ -257,7 +257,7 @@ public function testSetWsdl() public function testGetWsdl() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getWsdl()); $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); @@ -266,7 +266,7 @@ public function testGetWsdl() public function testAddFunction() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); // Correct function should pass $server->addFunction('Zend_Soap_Server_TestFunc1'); @@ -285,7 +285,7 @@ public function testAddFunction() public function testAddBogusFunctionAsInteger() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); try { $server->addFunction(126); $this->fail('Invalid value should fail'); @@ -296,10 +296,10 @@ public function testAddBogusFunctionAsInteger() public function testAddBogusFunctionsAsString() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); try { - $server->addFunction('bogus_function'); + $server->addFunction('bogus_function'); $this->fail('Invalid function should fail.'); } catch (Zend_Soap_Server_Exception $e) { // success @@ -308,13 +308,13 @@ public function testAddBogusFunctionsAsString() public function testAddBogusFunctionsAsArray() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); try { - $functions = array('Zend_Soap_Server_TestFunc5', - 'bogus_function', - 'Zend_Soap_Server_TestFunc6'); - $server->addFunction($functions); + $functions = array('Zend_Soap_Server_TestFunc5', + 'bogus_function', + 'Zend_Soap_Server_TestFunc6'); + $server->addFunction($functions); $this->fail('Invalid function within a set of functions should fail'); } catch (Zend_Soap_Server_Exception $e) { // success @@ -333,7 +333,7 @@ public function testAddAllFunctionsSoapConstant() public function testSetClass() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); // Correct class name should pass try { @@ -345,7 +345,7 @@ public function testSetClass() public function testSetClassTwiceThrowsException() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); // Correct class name should pass try { @@ -371,7 +371,7 @@ public function testSetClassWithArguments() public function testSetBogusClassWithIntegerName() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); try { $server->setClass(465); @@ -383,7 +383,7 @@ public function testSetBogusClassWithIntegerName() public function testSetBogusClassWithUnknownClassName() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); try { $server->setClass('Zend_Soap_Server_Test_BogusClass'); @@ -428,7 +428,7 @@ public function testSetObject() public function testGetFunctions() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->addFunction('Zend_Soap_Server_TestFunc1'); @@ -448,7 +448,7 @@ public function testGetFunctions() 'Zend_Soap_Server_TestFunc3', 'Zend_Soap_Server_TestFunc4', 'Zend_Soap_Server_TestFunc5', - 'Zend_Soap_Server_TestFunc6' + 'Zend_Soap_Server_TestFunc6' ); $this->assertTrue($server->getFunctions() == $allAddedFunctions); } @@ -477,7 +477,7 @@ public function testGetFunctionsWithObjectAttached() public function testSetPersistence() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getPersistence()); $server->setPersistence(SOAP_PERSISTENCE_SESSION); @@ -501,13 +501,13 @@ public function testSetUnknownPersistenceStateThrowsException() $server->setPersistence('bogus'); $this->fail(); } catch(Zend_Soap_Server_Exception $e) { - + } } public function testGetPersistence() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertNull($server->getPersistence()); $server->setPersistence(SOAP_PERSISTENCE_SESSION); @@ -521,7 +521,7 @@ public function testGetLastRequest() return; } - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -549,7 +549,7 @@ public function testGetLastRequest() public function testSetReturnResponse() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertFalse($server->getReturnResponse()); @@ -562,7 +562,7 @@ public function testSetReturnResponse() public function testGetReturnResponse() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertFalse($server->getReturnResponse()); @@ -577,7 +577,7 @@ public function testGetLastResponse() return; } - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -625,7 +625,7 @@ public function testHandle() return; } - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setClass('Zend_Soap_Server_TestClass'); @@ -683,7 +683,7 @@ public function testHandle() */ public function testRegisterFaultException() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->registerFaultException("Zend_Soap_Server_Exception"); $server->registerFaultException(array("OutOfBoundsException", "BogusException")); @@ -700,7 +700,7 @@ public function testRegisterFaultException() */ public function testDeregisterFaultException() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->registerFaultException(array("OutOfBoundsException", "BogusException")); $ret = $server->deregisterFaultException("BogusException"); @@ -719,7 +719,7 @@ public function testDeregisterFaultException() */ public function testGetFaultExceptions() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $this->assertEquals(array(), $server->getFaultExceptions()); $server->registerFaultException("Exception"); @@ -728,7 +728,7 @@ public function testGetFaultExceptions() public function testFaultWithTextMessage() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $fault = $server->fault("Faultmessage!"); $this->assertTrue($fault instanceof SOAPFault); @@ -737,7 +737,7 @@ public function testFaultWithTextMessage() public function testFaultWithUnregisteredException() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $fault = $server->fault(new Exception("MyException")); $this->assertTrue($fault instanceof SOAPFault); @@ -747,7 +747,7 @@ public function testFaultWithUnregisteredException() public function testFaultWithRegisteredException() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $server->registerFaultException("Exception"); $fault = $server->fault(new Exception("MyException")); @@ -758,7 +758,7 @@ public function testFaultWithRegisteredException() public function testFautlWithBogusInput() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); $fault = $server->fault(array("Here", "There", "Bogus")); $this->assertContains("Unknown error", $fault->getMessage()); @@ -780,7 +780,7 @@ public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault() */ public function testHandlePhpErrors() { - $server = new Zend_Soap_Server(); + $server = new Zend_Soap_Server(); // Remove the following line when you implement this test. $this->markTestIncomplete( @@ -796,7 +796,7 @@ public function testLoadFunctionsIsNotImplemented() $server->loadFunctions("bogus"); $this->fail(); } catch(Zend_Soap_Server_Exception $e) { - + } } @@ -886,29 +886,29 @@ public function testSetAndGetWsdlCache() if (extension_loaded('soap')) { /** Local SOAP client */ -class Zend_Soap_Server_TestLocalSoapClient extends SoapClient +class Zend_Soap_Server_TestLocalSoapClient extends SoapClient { - /** - * Server object - * - * @var Zend_Soap_Server - */ - public $server; - - /** - * Local client constructor - * - * @param Zend_Soap_Server $server - * @param string $wsdl - * @param array $options - */ - function __construct(Zend_Soap_Server $server, $wsdl, $options) + /** + * Server object + * + * @var Zend_Soap_Server + */ + public $server; + + /** + * Local client constructor + * + * @param Zend_Soap_Server $server + * @param string $wsdl + * @param array $options + */ + function __construct(Zend_Soap_Server $server, $wsdl, $options) { $this->server = $server; - parent::__construct($wsdl, $options); + parent::__construct($wsdl, $options); } - function __doRequest($request, $location, $action, $version, $one_way = 0) + function __doRequest($request, $location, $action, $version, $one_way = 0) { ob_start(); $this->server->handle($request); diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 39c0d42c..22b0381f 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -54,7 +54,7 @@ public function testNestingObjectsDeepMakesNoSenseThrowingException() $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[][]'); $this->fail(); } catch(Zend_Soap_Wsdl_Exception $e) { - + } } diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index 3e298405..aa1ff5fa 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -138,7 +138,7 @@ public function testAddComplexTypeObject() public function testAddComplexTypeArrayOfObject() { - + $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest[]'); $this->assertEquals("tns:ArrayOfZend_soap_wsdl_sequencetest", $return); diff --git a/test/Wsdl/ElementTest.php b/test/Wsdl/ElementTest.php index 60975a82..a1b66523 100644 --- a/test/Wsdl/ElementTest.php +++ b/test/Wsdl/ElementTest.php @@ -54,7 +54,7 @@ public function testBindingElementApi() $binding = new Zend_Soap_Wsdl_Element_Binding(array(), "portName", $operations, "test"); $this->fail(); } catch(Zend_Soap_Wsdl_Exception $e) { - + } } @@ -114,7 +114,7 @@ public function testOperationElementApi() $collection = new Zend_Soap_Wsdl_Element_Collection("test"); $input = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); $output = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); - + $operation = new Zend_Soap_Wsdl_Element_Operation("name1", $input, $output, "test"); $this->assertEquals("name1", $operation->getName()); @@ -148,7 +148,7 @@ public function testServiceElementApi() $service = new Zend_Soap_Wsdl_Element_Service(array(), "address", $port, $binding, "test"); $this->fail(); } catch(Zend_Soap_Wsdl_Exception $e) { - + } try { diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php index b9fcf60d..34036d6d 100644 --- a/test/Wsdl/ParserTest.php +++ b/test/Wsdl/ParserTest.php @@ -89,7 +89,7 @@ public function testFactoryWithInvalidData() $parser = Zend_Soap_Wsdl_Parser::factory(null); $this->fail(); } catch(Zend_Soap_Wsdl_Exception $e) { - + } } diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 203e6b33..15cf654b 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -559,7 +559,7 @@ function testSettingUnknownStrategyThrowsException() $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_UnknownStrategyType'); $this->fail(); } catch(Zend_Soap_Wsdl_Exception $e) { - + } } diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index b14e8bcd..f6476d06 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -345,21 +345,21 @@ class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure class Zend_Soap_AutoDiscover_MyService { /** - * @param string $foo - * @return Zend_Soap_AutoDiscover_MyResponse[] + * @param string $foo + * @return Zend_Soap_AutoDiscover_MyResponse[] */ public function foo($foo) { } /** - * @param string $bar - * @return Zend_Soap_AutoDiscover_MyResponse[] + * @param string $bar + * @return Zend_Soap_AutoDiscover_MyResponse[] */ public function bar($bar) { } /** - * @param string $baz - * @return Zend_Soap_AutoDiscover_MyResponse[] + * @param string $baz + * @return Zend_Soap_AutoDiscover_MyResponse[] */ public function baz($baz) { } @@ -375,28 +375,28 @@ public function baz($baz) { class Zend_Soap_AutoDiscover_MyServiceSequence { /** - * @param string $foo - * @return string[] + * @param string $foo + * @return string[] */ public function foo($foo) { } /** - * @param string $bar - * @return string[] + * @param string $bar + * @return string[] */ public function bar($bar) { } /** - * @param string $baz - * @return string[] + * @param string $baz + * @return string[] */ public function baz($baz) { } /** - * @param string $baz - * @return string[][][] + * @param string $baz + * @return string[][][] */ public function bazNested($baz) { } @@ -437,7 +437,7 @@ class Zend_Soap_AutoDiscover_Recursion */ function Zend_Soap_AutoDiscover_OneWay($message) { - + } /** From 1225b69e70b893bc0462060d457504b442d6ee4c Mon Sep 17 00:00:00 2001 From: sgehrig Date: Thu, 19 Nov 2009 08:51:14 +0000 Subject: [PATCH 027/123] ZF-6954 allow empty user-agent git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19024 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Client.php | 24 ++++++++++++++++++++---- test/ClientTest.php | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index a38883aa..18f60aef 100644 --- a/src/Client.php +++ b/src/Client.php @@ -317,8 +317,18 @@ public function getOptions() $options['user_agent'] = $this->getUserAgent(); foreach ($options as $key => $value) { - if ($value == null) { - unset($options[$key]); + /* + * ugly hack as I don't know if checking for '=== null' + * breaks some other option + */ + if ($key == 'user_agent') { + if ($value === null) { + unset($options[$key]); + } + } else { + if ($value == null) { + unset($options[$key]); + } } } @@ -867,17 +877,23 @@ public function getWsdlCache() /** * Set the string to use in User-Agent header * - * @param string $userAgent + * @param string|null $userAgent * @return Zend_Soap_Client */ public function setUserAgent($userAgent) { - $this->_user_agent = (string)$userAgent; + if ($userAgent === null) { + $this->_user_agent = null; + } else { + $this->_user_agent = (string)$userAgent; + } return $this; } /** * Get current string to use in User-Agent header + * + * @return string|null */ public function getUserAgent() { diff --git a/test/ClientTest.php b/test/ClientTest.php index d1fc1b3f..ac170ad0 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -202,6 +202,27 @@ public function testGetAndSetUserAgentOption() $this->assertEquals('agent4', $options['user_agent']); } + /** + * @group ZF-6954 + */ + public function testUserAgentAllowsEmptyString() + { + $client = new Zend_Soap_Client(); + $this->assertNull($client->getUserAgent()); + $options = $client->getOptions(); + $this->assertArrayNotHasKey('user_agent', $options); + + $client->setUserAgent(''); + $this->assertEquals('', $client->getUserAgent()); + $options = $client->getOptions(); + $this->assertEquals('', $options['user_agent']); + + $client->setUserAgent(null); + $this->assertNull($client->getUserAgent()); + $options = $client->getOptions(); + $this->assertArrayNotHasKey('user_agent', $options); + } + public function testGetFunctions() { $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); From 8fcbd33876a9c89cf7e79894184ea16f6c3d6687 Mon Sep 17 00:00:00 2001 From: bkarwin Date: Fri, 11 Dec 2009 21:16:39 +0000 Subject: [PATCH 028/123] improve consistent use of TestHelper, code covering filtering, and @group tags git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19582 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/AllTests.php | 8 +++----- test/Wsdl/AllTests.php | 10 +++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/AllTests.php b/test/AllTests.php index 5a51e513..32b24319 100644 --- a/test/AllTests.php +++ b/test/AllTests.php @@ -19,15 +19,13 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ + +require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; + if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Zend_Soap_AllTests::main'); } -require_once dirname(__FILE__)."/../../TestHelper.php"; - -require_once 'PHPUnit/Framework/TestSuite.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - require_once 'Zend/Soap/ClientTest.php'; require_once 'Zend/Soap/ServerTest.php'; require_once 'Zend/Soap/WsdlTest.php'; diff --git a/test/Wsdl/AllTests.php b/test/Wsdl/AllTests.php index 61b222d9..58d5e95c 100644 --- a/test/Wsdl/AllTests.php +++ b/test/Wsdl/AllTests.php @@ -20,7 +20,11 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; +require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php'; + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Zend_Soap_Wsdl_AllTests::main'); +} require_once "ArrayOfTypeComplexStrategyTest.php"; require_once "ArrayOfTypeSequenceStrategyTest.php"; @@ -48,3 +52,7 @@ public static function suite() return $suite; } } + +if (PHPUnit_MAIN_METHOD == 'Zend_Soap_Wsdl_AllTests::main') { + Zend_Soap_Wsdl_AllTests::main(); +} From 4ccf76bde6b6aec957c5a24b9607634bb739eaf7 Mon Sep 17 00:00:00 2001 From: bkarwin Date: Wed, 6 Jan 2010 02:05:09 +0000 Subject: [PATCH 029/123] [ZF-8718] update copyright tags for 2010 git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20096 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 2 +- src/AutoDiscover/Exception.php | 2 +- src/Client.php | 4 +-- src/Client/Common.php | 2 +- src/Client/DotNet.php | 2 +- src/Client/Exception.php | 4 +-- src/Client/Local.php | 2 +- src/Server.php | 4 +-- src/Server/Exception.php | 4 +-- src/Wsdl.php | 2 +- src/Wsdl/Exception.php | 4 +-- src/Wsdl/Strategy/Abstract.php | 4 +-- src/Wsdl/Strategy/AnyType.php | 4 +-- src/Wsdl/Strategy/ArrayOfTypeComplex.php | 4 +-- src/Wsdl/Strategy/ArrayOfTypeSequence.php | 4 +-- src/Wsdl/Strategy/Composite.php | 4 +-- src/Wsdl/Strategy/DefaultComplexType.php | 4 +-- src/Wsdl/Strategy/Interface.php | 4 +-- test/AllTests.php | 4 +-- test/AutoDiscover/OnlineTest.php | 4 +-- test/AutoDiscoverTest.php | 4 +-- test/ClientTest.php | 4 +-- test/ServerTest.php | 4 +-- test/Wsdl/AllTests.php | 4 +-- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 4 +-- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 4 +-- test/Wsdl/CompositeStrategyTest.php | 4 +-- test/Wsdl/DefaultComplexTypeTest.php | 4 +-- test/Wsdl/ElementTest.php | 4 +-- test/Wsdl/ParserTest.php | 4 +-- test/WsdlTest.php | 4 +-- test/_files/commontypes.php | 28 +++++++++---------- test/_files/fulltests/server1.php | 8 +++--- test/_files/fulltests/server2.php | 6 ++-- 34 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 8f3add5b..1440e5ab 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage AutoDiscover - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php index f0600e88..dd1b75a9 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/AutoDiscover/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage AutoDiscover - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Client.php b/src/Client.php index 18f60aef..3fc620a3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -41,7 +41,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Client diff --git a/src/Client/Common.php b/src/Client/Common.php index b4eb28e8..d3eb8e21 100644 --- a/src/Client/Common.php +++ b/src/Client/Common.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 6c2a4801..8a630f08 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Client/Exception.php b/src/Client/Exception.php index f29a4f53..fc278a2c 100644 --- a/src/Client/Exception.php +++ b/src/Client/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Client/Local.php b/src/Client/Local.php index 685c92ea..09b43d36 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Client - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Server.php b/src/Server.php index 22db1271..469192c3 100644 --- a/src/Server.php +++ b/src/Server.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Server - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -31,7 +31,7 @@ * @package Zend_Soap * @subpackage Server * @uses Zend_Server_Interface - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Server/Exception.php b/src/Server/Exception.php index db1e5eda..de19a674 100644 --- a/src/Server/Exception.php +++ b/src/Server/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Server - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -28,7 +28,7 @@ * @category Zend * @package Zend_Soap * @subpackage Server - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl.php b/src/Wsdl.php index b8df7d60..5c9ceb40 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ diff --git a/src/Wsdl/Exception.php b/src/Wsdl/Exception.php index 2d584829..fc6e43db 100644 --- a/src/Wsdl/Exception.php +++ b/src/Wsdl/Exception.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_Exception extends Zend_Exception { } \ No newline at end of file diff --git a/src/Wsdl/Strategy/Abstract.php b/src/Wsdl/Strategy/Abstract.php index d7844560..220807e2 100644 --- a/src/Wsdl/Strategy/Abstract.php +++ b/src/Wsdl/Strategy/Abstract.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Soap_Wsdl_Strategy_Abstract implements Zend_Soap_Wsdl_Strategy_Interface diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php index 23c4d1f2..813c9955 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php index 342a0e73..7fb0a63b 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_DefaultComplexType diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php index 71a10e22..bbbd4740 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_DefaultComplexType diff --git a/src/Wsdl/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php index 4b063e04..39fd70a0 100644 --- a/src/Wsdl/Strategy/Composite.php +++ b/src/Wsdl/Strategy/Composite.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index 65fb382a..ba7d1a16 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -31,7 +31,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract diff --git a/src/Wsdl/Strategy/Interface.php b/src/Wsdl/Strategy/Interface.php index 6927c81a..456bc6ea 100644 --- a/src/Wsdl/Strategy/Interface.php +++ b/src/Wsdl/Strategy/Interface.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -26,7 +26,7 @@ * @category Zend * @package Zend_Soap * @subpackage Wsdl - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ interface Zend_Soap_Wsdl_Strategy_Interface diff --git a/test/AllTests.php b/test/AllTests.php index 32b24319..d70e6175 100644 --- a/test/AllTests.php +++ b/test/AllTests.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -38,7 +38,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index 3336a407..ec95b2de 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -30,7 +30,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 518a9db1..d6629f4e 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -43,7 +43,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ diff --git a/test/ClientTest.php b/test/ClientTest.php index ac170ad0..0f086d61 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -41,7 +41,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ diff --git a/test/ServerTest.php b/test/ServerTest.php index 5046b7c7..4e28f77b 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -39,7 +39,7 @@ * @package Zend_Soap * @subpackage UnitTests * @uses Zend_Server_Interface - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Server diff --git a/test/Wsdl/AllTests.php b/test/Wsdl/AllTests.php index 58d5e95c..df2c3757 100644 --- a/test/Wsdl/AllTests.php +++ b/test/Wsdl/AllTests.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -34,7 +34,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 22b0381f..2c975809 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -32,7 +32,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index aa1ff5fa..e2dab952 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -38,7 +38,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php index 40e26128..24d915f6 100644 --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -14,7 +14,7 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -40,7 +40,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index 967c4bb4..cd4d56cf 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -29,7 +29,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/Wsdl/ElementTest.php b/test/Wsdl/ElementTest.php index a1b66523..9f42c0fb 100644 --- a/test/Wsdl/ElementTest.php +++ b/test/Wsdl/ElementTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -33,7 +33,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php index 34036d6d..39ff5c08 100644 --- a/test/Wsdl/ParserTest.php +++ b/test/Wsdl/ParserTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -29,7 +29,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 15cf654b..50eebb39 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -40,7 +40,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index f6476d06..b93ddfdd 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -118,7 +118,7 @@ function Zend_Soap_AutoDiscover_TestFunc9($foo, $bar) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes @@ -141,7 +141,7 @@ function testFunc($a=100, $b=200, $d=300) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_Test { @@ -206,7 +206,7 @@ class Zend_Soap_AutoDiscoverTestClass1 * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscoverTestClass2 @@ -245,7 +245,7 @@ public function addMultiple($test) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeB @@ -264,7 +264,7 @@ class Zend_Soap_Wsdl_ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeA @@ -279,7 +279,7 @@ class Zend_Soap_Wsdl_ComplexTypeA * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTest @@ -294,7 +294,7 @@ class Zend_Soap_Wsdl_ComplexTest * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexObjectStructure @@ -324,7 +324,7 @@ class Zend_Soap_Wsdl_ComplexObjectStructure * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure @@ -339,7 +339,7 @@ class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_MyService @@ -369,7 +369,7 @@ public function baz($baz) { * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_MyServiceSequence @@ -406,7 +406,7 @@ public function bazNested($baz) { * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_MyResponse @@ -421,7 +421,7 @@ class Zend_Soap_AutoDiscover_MyResponse * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_Recursion @@ -444,7 +444,7 @@ function Zend_Soap_AutoDiscover_OneWay($message) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_NoReturnType diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php index cc10b773..3d32ef35 100644 --- a/test/_files/fulltests/server1.php +++ b/test/_files/fulltests/server1.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -28,7 +28,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Service_Server1 @@ -61,7 +61,7 @@ public function request($request) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeB @@ -80,7 +80,7 @@ class Zend_Soap_Wsdl_ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeA diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index 680ae5c5..c9455527 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -15,7 +15,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ @@ -28,7 +28,7 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeB @@ -47,7 +47,7 @@ class Zend_Soap_Wsdl_ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Service_Server2 From b8ebdd54baef8fc9694456e69e772490d9828211 Mon Sep 17 00:00:00 2001 From: "yoshida@zend.co.jp" Date: Thu, 28 Jan 2010 05:34:27 +0000 Subject: [PATCH 030/123] [ZF-8949]TYPO in Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex exception. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20711 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/ArrayOfTypeComplex.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php index 7fb0a63b..1ea69b5d 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -48,7 +48,7 @@ public function addComplexType($type) { if(in_array($type, $this->_inProcess)) { require_once "Zend/Soap/Wsdl/Exception.php"; - throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itsself."); + throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itself."); } $this->_inProcess[$type] = $type; @@ -123,7 +123,7 @@ protected function _getXsdComplexTypeName($type) } /** - * From a nested defintion with type[], get the singular PHP Type + * From a nested definition with type[], get the singular PHP Type * * @param string $type * @return string From eb0dedcf87f9324778bb8f750249de782522ead6 Mon Sep 17 00:00:00 2001 From: matthew Date: Wed, 3 Mar 2010 20:46:05 +0000 Subject: [PATCH 031/123] [2.0] Stripped require_once calls (skipping Zend_Gdata, Zend_Pdf, Zend_Search, and Zend_Service components) git-svn-id: http://framework.zend.com/svn/framework/standard/branches/development-2.0@21309 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 41 ++++------------------- src/AutoDiscover/Exception.php | 6 +--- src/Client.php | 38 +++------------------ src/Client/Common.php | 1 + src/Client/DotNet.php | 6 ++-- src/Client/Exception.php | 4 +-- src/Client/Local.php | 8 ++--- src/Server.php | 37 +++----------------- src/Server/Exception.php | 6 +--- src/Wsdl.php | 23 ++++--------- src/Wsdl/Exception.php | 8 ++--- src/Wsdl/Strategy/Abstract.php | 6 +--- src/Wsdl/Strategy/AnyType.php | 8 ++--- src/Wsdl/Strategy/ArrayOfTypeComplex.php | 12 ++----- src/Wsdl/Strategy/ArrayOfTypeSequence.php | 6 +--- src/Wsdl/Strategy/Composite.php | 25 ++------------ src/Wsdl/Strategy/DefaultComplexType.php | 9 ++--- 17 files changed, 45 insertions(+), 199 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 1440e5ab..ed721490 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -20,30 +20,15 @@ * @version $Id$ */ -/** - * @see Zend_Server_Interface - */ -require_once 'Zend/Server/Interface.php'; -/** - * @see Zend_Soap_Wsdl - */ -require_once 'Zend/Soap/Wsdl.php'; -/** - * @see Zend_Server_Reflection - */ -require_once 'Zend/Server/Reflection.php'; -/** - * @see Zend_Server_Abstract - */ -require_once 'Zend/Server/Abstract.php'; -/** - * @see Zend_Uri - */ -require_once 'Zend/Uri.php'; - /** * Zend_Soap_AutoDiscover * + * @uses Zend_Server_Abstract + * @uses Zend_Server_Interface + * @uses Zend_Server_Reflection + * @uses Zend_Soap_AutoDiscover_Exception + * @uses Zend_Soap_Wsdl + * @uses Zend_Uri * @category Zend * @package Zend_Soap * @subpackage AutoDiscover @@ -118,7 +103,6 @@ public function __construct($strategy = true, $uri=null) public function setUri($uri) { if(!is_string($uri) && !($uri instanceof Zend_Uri)) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance."); } $this->_uri = $uri; @@ -163,7 +147,6 @@ public function getUri() public function setOperationBodyStyle(array $operationStyle=array()) { if(!isset($operationStyle['use'])) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("Key 'use' is required in Operation soap:body style."); } $this->_operationBodyStyle = $operationStyle; @@ -350,7 +333,6 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } } if ($prototype === null) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("No prototypes could be found for the '" . $function->getName() . "' function"); } @@ -445,7 +427,6 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) */ public function fault($fault = null, $code = null) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); } @@ -472,10 +453,6 @@ public function dump($filename) if($this->_wsdl !== null) { return $this->_wsdl->dump($filename); } else { - /** - * @see Zend_Soap_AutoDiscover_Exception - */ - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet."); } } @@ -488,10 +465,6 @@ public function toXml() if($this->_wsdl !== null) { return $this->_wsdl->toXml(); } else { - /** - * @see Zend_Soap_AutoDiscover_Exception - */ - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("Cannot return autodiscovered contents, WSDL file has not been generated yet."); } } @@ -513,7 +486,6 @@ public function getFunctions() */ public function loadFunctions($definition) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); } @@ -524,7 +496,6 @@ public function loadFunctions($definition) */ public function setPersistence($mode) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); } diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php index dd1b75a9..2a43d493 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/AutoDiscover/Exception.php @@ -21,11 +21,7 @@ */ /** - * @see Zend_Exception - */ -require_once "Zend/Exception.php"; - -/** + * @uses Zend_Exception * @package Zend_Soap * @subpackage AutoDiscover */ diff --git a/src/Client.php b/src/Client.php index 3fc620a3..f8727719 100644 --- a/src/Client.php +++ b/src/Client.php @@ -20,24 +20,13 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Server - */ -require_once 'Zend/Soap/Server.php'; - -/** - * @see Zend_Soap_Client_Local - */ -require_once 'Zend/Soap/Client/Local.php'; - -/** - * @see Zend_Soap_Client_Common - */ -require_once 'Zend/Soap/Client/Common.php'; - /** * Zend_Soap_Client * + * @uses Zend_Soap_Client_Common + * @uses Zend_Soap_Client_Exception + * @uses Zend_Soap_Client_Local + * @uses Zend_Soap_Server * @category Zend * @package Zend_Soap * @subpackage Client @@ -148,7 +137,6 @@ class Zend_Soap_Client public function __construct($wsdl = null, $options = null) { if (!extension_loaded('soap')) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.'); } @@ -275,7 +263,6 @@ public function setOptions($options) // break; default: - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Unknown SOAP client option'); break; } @@ -345,7 +332,6 @@ public function getOptions() public function setSoapVersion($version) { if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.'); } $this->_soapVersion = $version; @@ -376,7 +362,6 @@ public function setClassmap(array $classmap) { foreach ($classmap as $type => $class) { if (!class_exists($class)) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid class in class map'); } } @@ -408,7 +393,6 @@ public function getClassmap() public function setEncoding($encoding) { if (!is_string($encoding)) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid encoding specified'); } @@ -440,7 +424,6 @@ public function validateUrn($urn) { $scheme = parse_url($urn, PHP_URL_SCHEME); if ($scheme === false || $scheme === null) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid URN'); } @@ -516,7 +499,6 @@ public function getLocation() public function setStyle($style) { if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); } @@ -547,7 +529,6 @@ public function getStyle() public function setEncodingMethod($use) { if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); } @@ -718,7 +699,6 @@ public function setProxyPassword($proxyPassword) public function setHttpsCertificate($localCert) { if (!is_readable($localCert)) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.'); } @@ -807,10 +787,6 @@ public function getProxyPassword() public function setStreamContext($context) { if(!is_resource($context) || get_resource_type($context) !== "stream-context") { - /** - * @see Zend_Soap_Client_Exception - */ - require_once "Zend/Soap/Client/Exception.php"; throw new Zend_Soap_Client_Exception( "Invalid stream context resource given." ); @@ -1002,20 +978,16 @@ protected function _initSoapClientObject() if ($wsdl == null) { if (!isset($options['location'])) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.'); } if (!isset($options['uri'])) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.'); } } else { if (isset($options['use'])) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.'); } if (isset($options['style'])) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.'); } } @@ -1128,7 +1100,6 @@ public function __call($name, $arguments) public function getFunctions() { if ($this->getWsdl() == null) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); } @@ -1152,7 +1123,6 @@ public function getFunctions() public function getTypes() { if ($this->getWsdl() == null) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); } diff --git a/src/Client/Common.php b/src/Client/Common.php index d3eb8e21..21220e92 100644 --- a/src/Client/Common.php +++ b/src/Client/Common.php @@ -24,6 +24,7 @@ if (extension_loaded('soap')) { /** + * @uses SoapClient * @category Zend * @package Zend_Soap * @subpackage Client diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 8a630f08..87711674 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -20,9 +20,6 @@ * @version $Id$ */ -/** Zend_Soap_Client */ -require_once 'Zend/Soap/Client.php'; - if (extension_loaded('soap')) { /** @@ -34,6 +31,8 @@ * Please leave your notes, compatiblity issues reports or * suggestions in fw-webservices@lists.zend.com or fw-general@lists.com * + * @uses Zend_Soap_Client + * @uses Zend_Soap_Client_Exception * @category Zend * @package Zend_Soap * @subpackage Client @@ -68,7 +67,6 @@ protected function _preProcessArguments($arguments) if (count($arguments) > 1 || (count($arguments) == 1 && !is_array(reset($arguments))) ) { - require_once 'Zend/Soap/Client/Exception.php'; throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); } diff --git a/src/Client/Exception.php b/src/Client/Exception.php index fc278a2c..7b535c06 100644 --- a/src/Client/Exception.php +++ b/src/Client/Exception.php @@ -19,10 +19,8 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** Zend_Exception */ -require_once 'Zend/Exception.php'; - /** + * @uses Zend_Exception * @category Zend * @package Zend_Soap * @subpackage Client diff --git a/src/Client/Local.php b/src/Client/Local.php index 09b43d36..e6bffc49 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -20,12 +20,6 @@ * @version $Id$ */ -/** Zend_Soap_Server */ -require_once 'Zend/Soap/Server.php'; - -/** Zend_Soap_Client */ -require_once 'Zend/Soap/Client.php'; - if (extension_loaded('soap')) { /** @@ -36,6 +30,8 @@ * * Could be used for development or testing purposes. * + * @uses Zend_Soap_Client + * @uses Zend_Soap_Server * @category Zend * @package Zend_Soap * @subpackage Client diff --git a/src/Server.php b/src/Server.php index 469192c3..e90a2f22 100644 --- a/src/Server.php +++ b/src/Server.php @@ -19,18 +19,17 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @see Zend_Server_Interface - */ -require_once 'Zend/Server/Interface.php'; - /** * Zend_Soap_Server * + * @uses DOMDocument + * @uses SoapFault + * @uses SoapServer + * @uses Zend_Server_Interface + * @uses Zend_Soap_Server_Exception * @category Zend * @package Zend_Soap * @subpackage Server - * @uses Zend_Server_Interface * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ @@ -160,7 +159,6 @@ class Zend_Soap_Server implements Zend_Server_Interface public function __construct($wsdl = null, array $options = null) { if (!extension_loaded('soap')) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('SOAP extension is not loaded.'); } @@ -272,7 +270,6 @@ public function getOptions() public function setEncoding($encoding) { if (!is_string($encoding)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid encoding specified'); } @@ -300,7 +297,6 @@ public function getEncoding() public function setSoapVersion($version) { if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid soap version specified'); } @@ -329,7 +325,6 @@ public function validateUrn($urn) { $scheme = parse_url($urn, PHP_URL_SCHEME); if ($scheme === false || $scheme === null) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid URN'); } @@ -397,18 +392,10 @@ public function getUri() public function setClassmap($classmap) { if (!is_array($classmap)) { - /** - * @see Zend_Soap_Server_Exception - */ - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Classmap must be an array'); } foreach ($classmap as $type => $class) { if (!class_exists($class)) { - /** - * @see Zend_Soap_Server_Exception - */ - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid class in class map'); } } @@ -512,7 +499,6 @@ public function addFunction($function, $namespace = '') if (is_string($func) && function_exists($func)) { $this->_functions[] = $func; } else { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('One or more invalid functions specified in array'); } } @@ -522,7 +508,6 @@ public function addFunction($function, $namespace = '') } elseif ($function == SOAP_FUNCTIONS_ALL) { $this->_functions = SOAP_FUNCTIONS_ALL; } else { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid function specified'); } @@ -549,17 +534,14 @@ public function addFunction($function, $namespace = '') public function setClass($class, $namespace = '', $argv = null) { if (isset($this->_class)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('A class has already been registered with this soap server instance'); } if (!is_string($class)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid class argument (' . gettype($class) . ')'); } if (!class_exists($class)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Class "' . $class . '" does not exist'); } @@ -584,12 +566,10 @@ public function setClass($class, $namespace = '', $argv = null) public function setObject($object) { if(!is_object($object)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid object argument ('.gettype($object).')'); } if(isset($this->_object)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance'); } @@ -629,7 +609,6 @@ public function getFunctions() */ public function loadFunctions($definition) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Unimplemented'); } @@ -642,7 +621,6 @@ public function loadFunctions($definition) public function setPersistence($mode) { if (!in_array($mode, array(SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST))) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid persistence mode specified'); } @@ -690,7 +668,6 @@ protected function _setRequest($request) $dom = new DOMDocument(); if(strlen($xml) == 0 || !$dom->loadXML($xml)) { - require_once 'Zend/Soap/Server/Exception.php'; throw new Zend_Soap_Server_Exception('Invalid XML'); } } @@ -809,10 +786,6 @@ public function handle($request = null) $displayErrorsOriginalState = $this->_initializeSoapErrorContext(); $setRequestException = null; - /** - * @see Zend_Soap_Server_Exception - */ - require_once 'Zend/Soap/Server/Exception.php'; try { $this->_setRequest($request); } catch (Zend_Soap_Server_Exception $e) { diff --git a/src/Server/Exception.php b/src/Server/Exception.php index de19a674..03efb738 100644 --- a/src/Server/Exception.php +++ b/src/Server/Exception.php @@ -19,12 +19,8 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ - -/** Zend_Exception */ -require_once 'Zend/Exception.php'; - - /** + * @uses Zend_Exception * @category Zend * @package Zend_Soap * @subpackage Server diff --git a/src/Wsdl.php b/src/Wsdl.php index 5c9ceb40..5aef7537 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -19,19 +19,16 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_Interface - */ -require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; - -/** - * @see Zend_Soap_Wsdl_Strategy_Abstract - */ -require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; - /** * Zend_Soap_Wsdl * + * @uses DOMDocument + * @uses Zend_Server_Exception + * @uses Zend_Soap_Wsdl_Exception + * @uses Zend_Soap_Wsdl_Strategy_Abstract + * @uses Zend_Soap_Wsdl_Strategy_AnyType + * @uses Zend_Soap_Wsdl_Strategy_DefaultComplexType + * @uses Zend_Soap_Wsdl_Strategy_Interface * @category Zend * @package Zend_Soap */ @@ -98,7 +95,6 @@ public function __construct($name, $uri, $strategy = true) xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>"; $this->_dom = new DOMDocument(); if (!$this->_dom->loadXML($wsdl)) { - require_once 'Zend/Server/Exception.php'; throw new Zend_Server_Exception('Unable to create DomDocument'); } else { $this->_wsdl = $this->_dom->documentElement; @@ -142,16 +138,13 @@ public function setUri($uri) public function setComplexTypeStrategy($strategy) { if($strategy === true) { - require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; $strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType(); } else if($strategy === false) { - require_once "Zend/Soap/Wsdl/Strategy/AnyType.php"; $strategy = new Zend_Soap_Wsdl_Strategy_AnyType(); } else if(is_string($strategy)) { if(class_exists($strategy)) { $strategy = new $strategy(); } else { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception( sprintf("Strategy with name '%s does not exist.", $strategy )); @@ -159,7 +152,6 @@ public function setComplexTypeStrategy($strategy) } if(!($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface)) { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception("Set a strategy that is not of type 'Zend_Soap_Wsdl_Strategy_Interface'"); } $this->_strategy = $strategy; @@ -612,7 +604,6 @@ public function addComplexType($type) private function _parseElement($element) { if (!is_array($element)) { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception("The 'element' parameter needs to be an associative array."); } diff --git a/src/Wsdl/Exception.php b/src/Wsdl/Exception.php index fc6e43db..819074c2 100644 --- a/src/Wsdl/Exception.php +++ b/src/Wsdl/Exception.php @@ -20,18 +20,14 @@ * @version $Id$ */ -/** - * @see Zend_Exception - */ -require_once "Zend/Exception.php"; - /** * Zend_Soap_Wsdl_Exception * + * @uses Zend_Exception * @category Zend * @package Zend_Soap * @subpackage Wsdl * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Exception extends Zend_Exception { } \ No newline at end of file +class Zend_Soap_Wsdl_Exception extends Zend_Exception { } diff --git a/src/Wsdl/Strategy/Abstract.php b/src/Wsdl/Strategy/Abstract.php index 220807e2..e4f07bd4 100644 --- a/src/Wsdl/Strategy/Abstract.php +++ b/src/Wsdl/Strategy/Abstract.php @@ -20,14 +20,10 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_Interface - */ -require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; - /** * Abstract class for Zend_Soap_Wsdl_Strategy. * + * @uses Zend_Soap_Wsdl_Strategy_Interface * @category Zend * @package Zend_Soap * @subpackage Wsdl diff --git a/src/Wsdl/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php index 813c9955..b03ccf04 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -20,14 +20,10 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_Interface - */ -require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; - /** * Zend_Soap_Wsdl_Strategy_AnyType * + * @uses Zend_Soap_Wsdl_Strategy_Interface * @category Zend * @package Zend_Soap * @subpackage Wsdl @@ -56,4 +52,4 @@ public function addComplexType($type) { return 'xsd:anyType'; } -} \ No newline at end of file +} diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php index 1ea69b5d..33f4d354 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -20,14 +20,11 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_DefaultComplexType - */ -require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; - /** * Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex * + * @uses Zend_Soap_Wsdl_Exception + * @uses Zend_Soap_Wsdl_Strategy_DefaultComplexType * @category Zend * @package Zend_Soap * @subpackage Wsdl @@ -47,7 +44,6 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy public function addComplexType($type) { if(in_array($type, $this->_inProcess)) { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itself."); } $this->_inProcess[$type] = $type; @@ -55,7 +51,6 @@ public function addComplexType($type) $nestingLevel = $this->_getNestedCount($type); if($nestingLevel > 1) { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception( "ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ". "one level. Use array object properties to return deep nested data. @@ -65,7 +60,6 @@ public function addComplexType($type) $singularType = $this->_getSingularPhpType($type); if(!class_exists($singularType)) { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception(sprintf( "Cannot add a complex type %s that is not an object or where ". "class could not be found in 'DefaultComplexType' strategy.", $type @@ -143,4 +137,4 @@ protected function _getNestedCount($type) { return substr_count($type, "[]"); } -} \ No newline at end of file +} diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php index bbbd4740..f5b0c288 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -19,14 +19,10 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_DefaultComplexType - */ -require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; - /** * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence * + * @uses Zend_Soap_Wsdl_Strategy_DefaultComplexType * @category Zend * @package Zend_Soap * @subpackage Wsdl diff --git a/src/Wsdl/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php index 39fd70a0..c4c31717 100644 --- a/src/Wsdl/Strategy/Composite.php +++ b/src/Wsdl/Strategy/Composite.php @@ -20,14 +20,11 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_Interface - */ -require_once "Zend/Soap/Wsdl/Strategy/Interface.php"; - /** * Zend_Soap_Wsdl_Strategy_Composite * + * @uses Zend_Soap_Wsdl_Exception + * @uses Zend_Soap_Wsdl_Strategy_Interface * @category Zend * @package Zend_Soap * @subpackage Wsdl @@ -83,10 +80,6 @@ public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_ public function connectTypeToStrategy($type, $strategy) { if(!is_string($type)) { - /** - * @see Zend_Soap_Wsdl_Exception - */ - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map."); } $this->_typeMap[$type] = $strategy; @@ -107,10 +100,6 @@ public function getDefaultStrategy() $strategy = new $strategy; } if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { - /** - * @see Zend_Soap_Wsdl_Exception - */ - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception( "Default Strategy for Complex Types is not a valid strategy object." ); @@ -136,10 +125,6 @@ public function getStrategyOfType($type) } if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { - /** - * @see Zend_Soap_Wsdl_Exception - */ - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception( "Strategy for Complex Type '".$type."' is not a valid strategy object." ); @@ -172,10 +157,6 @@ public function setContext(Zend_Soap_Wsdl $context) public function addComplexType($type) { if(!($this->_context instanceof Zend_Soap_Wsdl) ) { - /** - * @see Zend_Soap_Wsdl_Exception - */ - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception( "Cannot add complex type '".$type."', no context is set for this composite strategy." ); @@ -185,4 +166,4 @@ public function addComplexType($type) $strategy->setContext($this->_context); return $strategy->addComplexType($type); } -} \ No newline at end of file +} diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index ba7d1a16..2042f881 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -20,14 +20,12 @@ * @version $Id$ */ -/** - * @see Zend_Soap_Wsdl_Strategy_Abstract - */ -require_once "Zend/Soap/Wsdl/Strategy/Abstract.php"; - /** * Zend_Soap_Wsdl_Strategy_DefaultComplexType * + * @uses ReflectionClass + * @uses Zend_Soap_Wsdl_Exception + * @uses Zend_Soap_Wsdl_Strategy_Abstract * @category Zend * @package Zend_Soap * @subpackage Wsdl @@ -45,7 +43,6 @@ class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy public function addComplexType($type) { if(!class_exists($type)) { - require_once "Zend/Soap/Wsdl/Exception.php"; throw new Zend_Soap_Wsdl_Exception(sprintf( "Cannot add a complex type %s that is not an object or where ". "class could not be found in 'DefaultComplexType' strategy.", $type From b617968f59c6c39b170e8495b0c25789d3574cde Mon Sep 17 00:00:00 2001 From: rquadling Date: Mon, 8 Mar 2010 11:57:05 +0000 Subject: [PATCH 032/123] Change EOLs in output from \r\n and \r to \n. This removes any url encoded \r's in the output. Fix ZF-9305 git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21378 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wsdl.php b/src/Wsdl.php index 5c9ceb40..6ca8ecd1 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -424,7 +424,7 @@ public function addDocumentation($input_node, $documentation) } $doc = $this->_dom->createElement('documentation'); - $doc_cdata = $this->_dom->createTextNode($documentation); + $doc_cdata = $this->_dom->createTextNode(str_replace(array("\r\n", "\r"), "\n", $documentation)); $doc->appendChild($doc_cdata); if($node->hasChildNodes()) { From 4a6e9a42de76ea6027aca5e2c4dfcf19a7766418 Mon Sep 17 00:00:00 2001 From: rquadling Date: Mon, 8 Mar 2010 11:59:39 +0000 Subject: [PATCH 033/123] Allow the Zend_Soap_Wsdl class to be overridden in the AutoDiscovery process. This can allow non complex types declared in the DocBlocks to be translated to xsd types (xsd:token, xsd:datetime, etc.) if the name of the Zend_Soap_Wsdl subclass which overrides the getType() method is passed as the third parameter to the Zend_Soap_Wsdl constructor. Details of this issue are logged at http://framework.zend.com/issues/browse/ZF-9214 git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21379 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 46 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 1440e5ab..5a28ab26 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -91,13 +91,21 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface */ protected $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http'); + /** + * Name of the class to handle the WSDL creation. + * + * @var string + */ + protected $_wsdlClass = 'Zend_Soap_Wsdl'; + /** * Constructor * * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy * @param string|Zend_Uri $uri + * @param string $wsdlClass */ - public function __construct($strategy = true, $uri=null) + public function __construct($strategy = true, $uri=null, $wsdlClass=null) { $this->_reflection = new Zend_Server_Reflection(); $this->setComplexTypeStrategy($strategy); @@ -105,6 +113,10 @@ public function __construct($strategy = true, $uri=null) if($uri !== null) { $this->setUri($uri); } + + if($wsdlClass !== null) { + $this->setWsdlClass($wsdlClass); + } } /** @@ -150,6 +162,36 @@ public function getUri() return $uri; } + /** + * Set the name of the WSDL handling class. + * + * @see Zend_Soap_Exception + * @see Zend_Soap_Exception + * @throws Zend_Soap_AutoDiscover_Exception + * @param string $wsdlClass + * @return Zend_Soap_AutoDiscover + */ + public function setWsdlClass($wsdlClass) + { + if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend_Soap_Wsdl')) { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("No Zend_Soap_Wsdl subclass given to Zend_Soap_AutoDiscover::setWsdlClass as string."); + } + $this->_wsdlClass = $wsdlClass; + + return $this; + } + + /** + * Return the name of the WSDL handling class. + * + * @return string + */ + public function getWsdlClass() + { + return $this->_wsdlClass; + } + /** * Set options for all the binding operations soap:body elements. * @@ -268,7 +310,7 @@ public function setClass($class, $namespace = '', $argv = null) { $uri = $this->getUri(); - $wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy); + $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); From 9ae47503dcdd42023580faf62656ff39e4a66064 Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 8 Mar 2010 20:36:57 +0000 Subject: [PATCH 034/123] [2.0] Updated test suite - Created phpunit.xml - Renamed TestHelper.php Bootstrap.php; latter now referenced in phpunit.xml - Uses autoloading - Stripped require_once calls globally (will need to run individual groups iteratively to determine if any test caes are missing necessary calls) - Controller tests now run (but 4 new errors) git-svn-id: http://framework.zend.com/svn/framework/standard/branches/development-2.0@21390 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/AllTests.php | 70 ------------------- test/AutoDiscover/OnlineTest.php | 3 - test/AutoDiscoverTest.php | 6 -- test/ClientTest.php | 5 -- test/ServerTest.php | 5 -- test/Wsdl/AllTests.php | 58 --------------- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 4 -- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 4 -- test/Wsdl/CompositeStrategyTest.php | 10 +-- test/Wsdl/DefaultComplexTypeTest.php | 3 - test/Wsdl/ElementTest.php | 8 --- test/Wsdl/ParserTest.php | 4 -- test/WsdlTest.php | 4 -- test/_files/fulltests/server1.php | 3 - test/_files/fulltests/server2.php | 3 - 15 files changed, 1 insertion(+), 189 deletions(-) delete mode 100644 test/AllTests.php delete mode 100644 test/Wsdl/AllTests.php diff --git a/test/AllTests.php b/test/AllTests.php deleted file mode 100644 index d70e6175..00000000 --- a/test/AllTests.php +++ /dev/null @@ -1,70 +0,0 @@ -addTestSuite('Zend_Soap_ClientTest'); - $suite->addTestSuite('Zend_Soap_ServerTest'); - $suite->addTestSuite('Zend_Soap_WsdlTest'); - $suite->addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeComplexStrategyTest'); - $suite->addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeSequenceStrategyTest'); - $suite->addTestSuite('Zend_Soap_AutoDiscoverTest'); - $suite->addTestSuite('Zend_Soap_AutoDiscover_OnlineTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Soap_AllTests::main') { - Zend_Soap_AllTests::main(); -} diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index ec95b2de..5daa6e00 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -20,11 +20,8 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; -require_once dirname(__FILE__)."/../_files/commontypes.php"; /** Zend_Soap_Server */ -require_once 'Zend/Soap/Client.php'; /** * @category Zend diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index d6629f4e..148a73b8 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -20,22 +20,16 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../TestHelper.php"; /** PHPUnit Test Case */ -require_once 'PHPUnit/Framework/TestCase.php'; /** Zend_Soap_AutoDiscover */ -require_once 'Zend/Soap/AutoDiscover.php'; /** Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex */ -require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php"; /** Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence */ -require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php"; /** Include Common TestTypes */ -require_once "_files/commontypes.php"; /** * Test cases for Zend_Soap_AutoDiscover diff --git a/test/ClientTest.php b/test/ClientTest.php index 0f086d61..73f2aeb4 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -24,18 +24,13 @@ define('PHPUnit_MAIN_METHOD', 'Zend_Soap_ClientTest::main'); } -require_once dirname(__FILE__)."/../../TestHelper.php"; /** PHPUnit Test Case */ -require_once "PHPUnit/Framework/TestCase.php"; /** Zend_Soap_Server */ -require_once 'Zend/Soap/Server.php'; /** Zend_Soap_Client */ -require_once 'Zend/Soap/Client.php'; -require_once 'Zend/Config.php'; /** * @category Zend diff --git a/test/ServerTest.php b/test/ServerTest.php index 4e28f77b..5e740c46 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -20,17 +20,12 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../TestHelper.php"; /** PHPUnit Test Case */ -require_once "PHPUnit/Framework/TestCase.php"; /** Zend_Soap_Server */ -require_once 'Zend/Soap/Server.php'; -require_once 'Zend/Soap/Server/Exception.php'; -require_once "Zend/Config.php"; /** * Zend_Soap_Server diff --git a/test/Wsdl/AllTests.php b/test/Wsdl/AllTests.php deleted file mode 100644 index df2c3757..00000000 --- a/test/Wsdl/AllTests.php +++ /dev/null @@ -1,58 +0,0 @@ -addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeComplexStrategyTest'); - $suite->addTestSuite('Zend_Soap_Wsdl_ArrayOfTypeSequenceStrategyTest'); - $suite->addTestSuite('Zend_Soap_Wsdl_DefaultComplexTypeTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Soap_Wsdl_AllTests::main') { - Zend_Soap_Wsdl_AllTests::main(); -} diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 2c975809..7776bc3e 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -19,14 +19,10 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; -require_once dirname(__FILE__)."/../_files/commontypes.php"; /** Zend_Soap_Wsdl */ -require_once 'Zend/Soap/Wsdl.php'; /** Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex */ -require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php'; /** * @category Zend diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index e2dab952..c984b2ea 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -24,15 +24,11 @@ * @subpackage UnitTests */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; /** PHPUnit Test Case */ -require_once 'PHPUnit/Framework/TestCase.php'; /** Zend_Soap_Wsdl */ -require_once 'Zend/Soap/Wsdl.php'; -require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php'; /** * @category Zend diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php index 24d915f6..bc18b931 100644 --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -24,17 +24,9 @@ * @subpackage UnitTests */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; /** Zend_Soap_Wsdl */ -require_once 'Zend/Soap/Wsdl.php'; - -require_once 'Zend/Soap/Wsdl/Strategy/AnyType.php'; -require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php'; -require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php'; -require_once 'Zend/Soap/Wsdl/Strategy/DefaultComplexType.php'; -require_once 'Zend/Soap/Wsdl/Strategy/DefaultComplexType.php'; -require_once 'Zend/Soap/Wsdl/Strategy/Composite.php'; + /** * @category Zend diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index cd4d56cf..e6fa345e 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -20,10 +20,7 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; -require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php"; -require_once "Zend/Soap/Wsdl.php"; /** * @category Zend diff --git a/test/Wsdl/ElementTest.php b/test/Wsdl/ElementTest.php index 9f42c0fb..6b9b7395 100644 --- a/test/Wsdl/ElementTest.php +++ b/test/Wsdl/ElementTest.php @@ -20,14 +20,6 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; -require_once "Zend/Soap/Wsdl/Element/Binding.php"; -require_once "Zend/Soap/Wsdl/Element/Type.php"; -require_once "Zend/Soap/Wsdl/Element/Message.php"; -require_once "Zend/Soap/Wsdl/Element/Operation.php"; -require_once "Zend/Soap/Wsdl/Element/Port.php"; -require_once "Zend/Soap/Wsdl/Element/Service.php"; -require_once "Zend/Soap/Wsdl/Element/Collection.php"; /** * @category Zend diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php index 39ff5c08..4036fddc 100644 --- a/test/Wsdl/ParserTest.php +++ b/test/Wsdl/ParserTest.php @@ -20,10 +20,6 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../../TestHelper.php"; -require_once "Zend/Soap/Wsdl.php"; -require_once "Zend/Soap/Wsdl/Parser.php"; -require_once "Zend/Soap/Wsdl/Parser/Result.php"; /** * @category Zend diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 50eebb39..836c7532 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -20,18 +20,14 @@ * @version $Id$ */ -require_once dirname(__FILE__)."/../../TestHelper.php"; /** PHPUnit Test Case */ -require_once 'PHPUnit/Framework/TestCase.php'; /** Zend_Soap_Wsdl */ -require_once 'Zend/Soap/Wsdl.php'; /** * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence */ -require_once 'Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php'; /** diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php index 3d32ef35..dfed208f 100644 --- a/test/_files/fulltests/server1.php +++ b/test/_files/fulltests/server1.php @@ -20,9 +20,6 @@ * @version $Id$ */ -require_once "Zend/Soap/AutoDiscover.php"; -require_once "Zend/Soap/Server.php"; -require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php"; /** * @category Zend diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index c9455527..e321d49b 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -20,9 +20,6 @@ * @version $Id$ */ -require_once "Zend/Soap/AutoDiscover.php"; -require_once "Zend/Soap/Server.php"; -require_once "Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php"; /** * @category Zend From add5fa28e578f728cef2429a599e19afbd9db712 Mon Sep 17 00:00:00 2001 From: matthew Date: Wed, 10 Mar 2010 19:34:20 +0000 Subject: [PATCH 035/123] [2.0] Zend_Soap tests now pass git-svn-id: http://framework.zend.com/svn/framework/standard/branches/development-2.0@21454 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 8 +++---- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 13 +--------- test/Wsdl/ElementTest.php | 4 ++-- test/Wsdl/ParserTest.php | 1 + test/WsdlTest.php | 24 ++++++++++--------- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 7776bc3e..e3dbf8ca 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -20,9 +20,7 @@ * @version $Id$ */ -/** Zend_Soap_Wsdl */ - -/** Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex */ +require_once dirname(__FILE__)."/../_files/commontypes.php"; /** * @category Zend @@ -57,7 +55,7 @@ public function testNestingObjectsDeepMakesNoSenseThrowingException() public function testAddComplexTypeOfNonExistingClassThrowsException() { try { - $this->wsdl->addComplexType('Zend_Soap_Wsdl_UnknownClass[]'); + $this->wsdl->addComplexType('Some_Soap_Wsdl_UnknownClass[]'); } catch(Zend_Soap_Wsdl_Exception $e) { } @@ -223,7 +221,7 @@ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrow $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); } catch(Exception $e) { $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itsself.", $e->getMessage()); + $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itself.", $e->getMessage()); } } } diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index c984b2ea..23eceed2 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -19,17 +19,6 @@ * @version $Id$ */ -/** - * @package Zend_Soap - * @subpackage UnitTests - */ - - -/** PHPUnit Test Case */ - -/** Zend_Soap_Wsdl */ - - /** * @category Zend * @package Zend_Soap @@ -156,7 +145,7 @@ public function testAddComplexTypeOfNonExistingClassThrowsException() { $this->setExpectedException("Zend_Soap_Wsdl_Exception"); - $this->wsdl->addComplexType('Zend_Soap_Wsdl_UnknownClass[]'); + $this->wsdl->addComplexType('Some_Soap_Wsdl_UnknownClass[]'); } } diff --git a/test/Wsdl/ElementTest.php b/test/Wsdl/ElementTest.php index 6b9b7395..99067b85 100644 --- a/test/Wsdl/ElementTest.php +++ b/test/Wsdl/ElementTest.php @@ -20,15 +20,15 @@ * @version $Id$ */ - /** - * @category Zend + * @category Zend; * @package Zend_Soap * @subpackage UnitTests * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl + * @group disable */ class Zend_Soap_Wsdl_ElementTest extends PHPUnit_Framework_TestCase { diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php index 4036fddc..ef73e164 100644 --- a/test/Wsdl/ParserTest.php +++ b/test/Wsdl/ParserTest.php @@ -29,6 +29,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl + * @group disable */ class Zend_Soap_Wsdl_ParserTest extends PHPUnit_Framework_TestCase { diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 836c7532..095a95d8 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -20,16 +20,6 @@ * @version $Id$ */ - -/** PHPUnit Test Case */ - -/** Zend_Soap_Wsdl */ - -/** - * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence - */ - - /** * Test cases for Zend_Soap_Wsdl * @@ -50,6 +40,13 @@ protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) return $xmlstring; } + public function swallowIncludeNotices($errno, $errstr) + { + if ($errno != E_WARNING || !strstr($errstr, 'failed')) { + return false; + } + } + function testConstructor() { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); @@ -549,14 +546,19 @@ function testGetComplexTypeBasedOnStrategiesStringNames() $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType); } + /** + * @outputBuffering enabled + */ function testSettingUnknownStrategyThrowsException() { + set_error_handler(array($this, 'swallowIncludeNotices'), E_WARNING); try { $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_UnknownStrategyType'); + restore_error_handler(); $this->fail(); } catch(Zend_Soap_Wsdl_Exception $e) { - } + restore_error_handler(); } function testSettingInvalidStrategyObjectThrowsException() From f0770d77b26ba8e63bac21a87803d094b06d41bb Mon Sep 17 00:00:00 2001 From: matthew Date: Tue, 16 Mar 2010 12:38:39 +0000 Subject: [PATCH 036/123] [2.0] Merged in changes from trunk up to r21517 git-svn-id: http://framework.zend.com/svn/framework/standard/branches/development-2.0@21518 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/AutoDiscover.php | 46 ++++++++++++++++++++++++++++++++++++++++++-- src/Wsdl.php | 2 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index ed721490..6d11f917 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -76,13 +76,21 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface */ protected $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http'); + /** + * Name of the class to handle the WSDL creation. + * + * @var string + */ + protected $_wsdlClass = 'Zend_Soap_Wsdl'; + /** * Constructor * * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy * @param string|Zend_Uri $uri + * @param string $wsdlClass */ - public function __construct($strategy = true, $uri=null) + public function __construct($strategy = true, $uri=null, $wsdlClass=null) { $this->_reflection = new Zend_Server_Reflection(); $this->setComplexTypeStrategy($strategy); @@ -90,6 +98,10 @@ public function __construct($strategy = true, $uri=null) if($uri !== null) { $this->setUri($uri); } + + if($wsdlClass !== null) { + $this->setWsdlClass($wsdlClass); + } } /** @@ -134,6 +146,36 @@ public function getUri() return $uri; } + /** + * Set the name of the WSDL handling class. + * + * @see Zend_Soap_Exception + * @see Zend_Soap_Exception + * @throws Zend_Soap_AutoDiscover_Exception + * @param string $wsdlClass + * @return Zend_Soap_AutoDiscover + */ + public function setWsdlClass($wsdlClass) + { + if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend_Soap_Wsdl')) { + require_once "Zend/Soap/AutoDiscover/Exception.php"; + throw new Zend_Soap_AutoDiscover_Exception("No Zend_Soap_Wsdl subclass given to Zend_Soap_AutoDiscover::setWsdlClass as string."); + } + $this->_wsdlClass = $wsdlClass; + + return $this; + } + + /** + * Return the name of the WSDL handling class. + * + * @return string + */ + public function getWsdlClass() + { + return $this->_wsdlClass; + } + /** * Set options for all the binding operations soap:body elements. * @@ -251,7 +293,7 @@ public function setClass($class, $namespace = '', $argv = null) { $uri = $this->getUri(); - $wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy); + $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); diff --git a/src/Wsdl.php b/src/Wsdl.php index 5aef7537..8f2e2c13 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -416,7 +416,7 @@ public function addDocumentation($input_node, $documentation) } $doc = $this->_dom->createElement('documentation'); - $doc_cdata = $this->_dom->createTextNode($documentation); + $doc_cdata = $this->_dom->createTextNode(str_replace(array("\r\n", "\r"), "\n", $documentation)); $doc->appendChild($doc_cdata); if($node->hasChildNodes()) { From bfccaa277cf861e78a28ad9ffb2af0448dcd4101 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 26 Mar 2010 12:53:24 -0400 Subject: [PATCH 037/123] Added PHPTools submodule --- .gitmodules | 3 +++ tools/phptools | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 tools/phptools diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..21d57da5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools/phptools"] + path = tools/phptools + url = git://github.com/ralphschindler/PHPTools.git diff --git a/tools/phptools b/tools/phptools new file mode 160000 index 00000000..685f0e09 --- /dev/null +++ b/tools/phptools @@ -0,0 +1 @@ +Subproject commit 685f0e09aabbc45d82d3836aefc82be1efddb513 From d7b7ae1479ac915ac8261a0474f68a3886985706 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 26 Mar 2010 13:49:44 -0400 Subject: [PATCH 038/123] Updated PHPTools --- tools/phptools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/phptools b/tools/phptools index 685f0e09..d232cb3e 160000 --- a/tools/phptools +++ b/tools/phptools @@ -1 +1 @@ -Subproject commit 685f0e09aabbc45d82d3836aefc82be1efddb513 +Subproject commit d232cb3e4f1448daccefc74882da1862cda7656f From 67509fdec61abd75eb34cfa8eec054e51f2b1a53 Mon Sep 17 00:00:00 2001 From: matthew Date: Wed, 31 Mar 2010 17:44:39 +0000 Subject: [PATCH 039/123] [RELEASE] Backported 21707 to trunk git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21712 44c647ce-9c0f-0410-b52a-842ac1e357ba --- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 2c975809..94db482c 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -227,7 +227,7 @@ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrow $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); } catch(Exception $e) { $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itsself.", $e->getMessage()); + $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itself.", $e->getMessage()); } } } From 4eea486aae4cb2fbc49a262a04e5f7f1076cb20e Mon Sep 17 00:00:00 2001 From: beberlei Date: Thu, 15 Apr 2010 19:58:12 +0000 Subject: [PATCH 040/123] ZF-8948, ZF-5766 - Allow recursive object graph in complex types git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21858 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/ArrayOfTypeComplex.php | 5 +- test/AutoDiscoverTest.php | 34 +++ test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 8 +- test/Wsdl/ElementTest.php | 246 ------------------- test/Wsdl/ParserTest.php | 188 -------------- test/_files/commontypes.php | 5 + 6 files changed, 43 insertions(+), 443 deletions(-) delete mode 100644 test/Wsdl/ElementTest.php delete mode 100644 test/Wsdl/ParserTest.php diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php index 1ea69b5d..40a591a0 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -46,9 +46,8 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy */ public function addComplexType($type) { - if(in_array($type, $this->_inProcess)) { - require_once "Zend/Soap/Wsdl/Exception.php"; - throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itself."); + if (in_array($type, $this->_inProcess)) { + return "tns:" . $type; } $this->_inProcess[$type] = $type; diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index d6629f4e..0086b479 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -904,4 +904,38 @@ public function testNoReturnIsOneWayCallInAddFunction() $wsdl ); } + + /** + * @group ZF-8948 + * @group ZF-5766 + */ + public function testRecursiveWsdlDependencies() + { + $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); + $autodiscover->setClass('Zend_Soap_AutoDiscover_Recursion'); + $wsdl = $autodiscover->toXml(); + + // + // + // + // + // + + + $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="Zend_Soap_AutoDiscover_Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:Zend_Soap_AutoDiscover_Recursion"]'; + $this->assertWsdlPathExists($wsdl, $path); + } + + public function assertWsdlPathExists($xml, $path) + { + $doc = new DOMDocument('UTF-8'); + $doc->loadXML($xml); + + $xpath = new DOMXPath($doc); + $xpath->registerNamespace('wsdl', 'http://schemas.xmlsoap.org/wsdl/'); + + $nodes = $xpath->query($path); + + $this->assertTrue($nodes->length >= 1, "Could not assert that XML Document contains a node that matches the XPath Expression: " . $path); + } } diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 94db482c..1ecf3bae 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -220,14 +220,10 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllType /** * @group ZF-5754 + * @group ZF-8948 */ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() { - try { - $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itself.", $e->getMessage()); - } + $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); } } diff --git a/test/Wsdl/ElementTest.php b/test/Wsdl/ElementTest.php deleted file mode 100644 index 9f42c0fb..00000000 --- a/test/Wsdl/ElementTest.php +++ /dev/null @@ -1,246 +0,0 @@ -assertEquals("name1", $binding->getName()); - $this->assertEquals("port1", $binding->portName); - $this->assertEquals($operations, $binding->operations); - $this->assertEquals("test", $binding->getDocumentation()); - - try { - $binding = new Zend_Soap_Wsdl_Element_Binding(array(), "portName", $operations, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testTypeElementApi() - { - $types = new Zend_Soap_Wsdl_Element_Collection("test"); - $type = new Zend_Soap_Wsdl_Element_Type("name1", $types, "test"); - - $this->assertEquals("name1", $type->getName()); - $this->assertEquals($types, $type->types); - $this->assertEquals("test", $type->getDocumentation()); - - try { - $type = new Zend_Soap_Wsdl_Element_Type(array(), $types, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testMessageElementApi() - { - $parts = new Zend_Soap_Wsdl_Element_Collection("test"); - $message = new Zend_Soap_Wsdl_Element_Message("name1", $parts, "test"); - - $this->assertEquals("name1", $message->getName()); - $this->assertEquals($parts, $message->parts); - $this->assertEquals("test", $message->getDocumentation()); - - try { - $message = new Zend_Soap_Wsdl_Element_Message(array(), $parts, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testPortElementApi() - { - $operations = new Zend_Soap_Wsdl_Element_Collection("test"); - $port = new Zend_Soap_Wsdl_Element_Port("name1", $operations, "test"); - - $this->assertEquals("name1", $port->getName()); - $this->assertEquals($operations, $port->operations); - $this->assertEquals("test", $port->getDocumentation()); - - try { - $port = new Zend_Soap_Wsdl_Element_Port(array(), $operations, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testOperationElementApi() - { - $collection = new Zend_Soap_Wsdl_Element_Collection("test"); - $input = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); - $output = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); - - $operation = new Zend_Soap_Wsdl_Element_Operation("name1", $input, $output, "test"); - - $this->assertEquals("name1", $operation->getName()); - $this->assertEquals($input, $operation->inputMessage); - $this->assertEquals($output, $operation->outputMessage); - $this->assertEquals("test", $operation->getDocumentation()); - - try { - $operation = new Zend_Soap_Wsdl_Element_Operation(array(), $input, $output, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testServiceElementApi() - { - $collection = new Zend_Soap_Wsdl_Element_Collection("test"); - $port = new Zend_Soap_Wsdl_Element_Port("name", $collection, "test"); - $binding = new Zend_Soap_Wsdl_Element_Binding("name", "port", $collection, "test"); - - $service = new Zend_Soap_Wsdl_Element_Service("service", "address", $port, $binding, "test"); - - $this->assertEquals("service", $service->getName()); - $this->assertEquals("address", $service->soapAddress); - $this->assertEquals($port, $service->port); - $this->assertEquals($binding, $service->binding); - $this->assertEquals("test", $service->getDocumentation()); - - try { - $service = new Zend_Soap_Wsdl_Element_Service(array(), "address", $port, $binding, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - - try { - $service = new Zend_Soap_Wsdl_Element_Service("name", array(), $port, $binding, "test"); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testCollectionElementApiConstruct() - { - $collection = new Zend_Soap_Wsdl_Element_Collection("Operation"); - - $this->assertTrue($collection instanceof Countable); - $this->assertTrue($collection instanceof Iterator); - - try { - $type = new Zend_Soap_Wsdl_Element_Type("type", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); - $collection->addElement($type); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - - try { - $collection = new Zend_Soap_Wsdl_Element_Collection(false); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testCollectionElementApiType() - { - $collection = new Zend_Soap_Wsdl_Element_Collection("Operation"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Operation", $collection->getType()); - - $collection = new Zend_Soap_Wsdl_Element_Collection("Type"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Type", $collection->getType()); - - $collection = new Zend_Soap_Wsdl_Element_Collection("Binding"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Binding", $collection->getType()); - - $collection = new Zend_Soap_Wsdl_Element_Collection("Service"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Service", $collection->getType()); - - $collection = new Zend_Soap_Wsdl_Element_Collection("Port"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Port", $collection->getType()); - - $collection = new Zend_Soap_Wsdl_Element_Collection("Message"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Message", $collection->getType()); - } - - public function testCollectionElementApiElementAccess() - { - $collection = new Zend_Soap_Wsdl_Element_Collection("Message"); - $message1 = new Zend_Soap_Wsdl_Element_Message("message1", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); - $message2 = new Zend_Soap_Wsdl_Element_Message("message2", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); - $messageDuplicate = new Zend_Soap_Wsdl_Element_Message("message2", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); - - $collection->addElement($message1); - $this->assertEquals(array("message1"), $collection->getElementNames()); - $this->assertEquals($message1, $collection->getElement("message1")); - $this->assertEquals(1, count($collection)); - - $collection->addElement($message2); - $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); - $this->assertEquals($message2, $collection->getElement("message2")); - $this->assertEquals(2, count($collection)); - - try { - // Adding duplicate message leads to exception - $collection->addElement($messageDuplicate); - $this->fail("Adding a duplicate named element to a collection should throw an exception."); - } catch(Zend_Soap_Wsdl_Exception $e) { - $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); - $this->assertEquals($message2, $collection->getElement("message2")); - $this->assertEquals(2, count($collection)); - } - - try { - // Accessing unkown message leads to exception - $collection->getElement("messageUnknown"); - $this->fail("Accessing unknown element should throw an exception."); - } catch(Zend_Soap_Wsdl_Exception $e) { - $this->assertEquals(2, count($collection)); - } - - foreach($collection AS $name => $message) { - $this->assertTrue($message instanceof Zend_Soap_Wsdl_Element_Message); - $this->assertTrue( in_array($name, $collection->getElementNames()) ); - } - } -} diff --git a/test/Wsdl/ParserTest.php b/test/Wsdl/ParserTest.php deleted file mode 100644 index 39ff5c08..00000000 --- a/test/Wsdl/ParserTest.php +++ /dev/null @@ -1,188 +0,0 @@ -loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl")); - return $dom; - } - - public function testFactoryWithDomDocument() - { - $dom = $this->getWsdlExampleDom(); - $parser = Zend_Soap_Wsdl_Parser::factory($dom); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); - } - - public function testFactoryWithString() - { - $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); - $parser = Zend_Soap_Wsdl_Parser::factory($xmlString); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); - } - - public function testFactoryWithSimpleXml() - { - $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); - $simpleXml = simplexml_load_string($xmlString); - $parser = Zend_Soap_Wsdl_Parser::factory($simpleXml); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); - } - - public function testFactoryWithZendSoapWsdl() - { - $wsdl = new Zend_Soap_Wsdl("name", "http://example.com"); - $parser = Zend_Soap_Wsdl_Parser::factory($wsdl); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); - } - - public function testFactoryWithInvalidParser() - { - $wsdl = new Zend_Soap_Wsdl("name", "http://example.com"); - try { - $parser = Zend_Soap_Wsdl_Parser::factory($wsdl, "stdClass"); - $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Parser_Exception); - } - } - - public function testFactoryWithInvalidData() - { - try { - $parser = Zend_Soap_Wsdl_Parser::factory(null); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testParserApiInterface() - { - // Constructor expects DOMDocument instance - $dom = $this->getWsdlExampleDom(); - $parser = new Zend_Soap_Wsdl_Parser($dom); - - // SetWsdl is a fluent function - $this->assertTrue( ($parser->setDomDocumentContainingWsdl($dom)) instanceof Zend_Soap_Wsdl_Parser ); - - // Parse returns Result - $result = $parser->parse(); - $this->assertTrue($result instanceof Zend_Soap_Wsdl_Parser_Result); - } - - public function testParserResultApiInterface() - { - $result = new Zend_Soap_Wsdl_Parser_Result( - "name", - Zend_Soap_Wsdl_Parser::WSDL_11, - new Zend_Soap_Wsdl_Element_Collection("Operation"), - new Zend_Soap_Wsdl_Element_Collection("Port"), - new Zend_Soap_Wsdl_Element_Collection("Binding"), - new Zend_Soap_Wsdl_Element_Collection("Service"), - new Zend_Soap_Wsdl_Element_Collection("Type"), - array("docs") - ); - - $this->assertEquals("name", $result->getName()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Operation", $result->operations->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Port", $result->ports->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Binding", $result->bindings->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Service", $result->services->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Type", $result->types->getType()); - $this->assertEquals(array("docs"), $result->documentation); - - try { - $key = $result->invalidKeyThrowsException; - $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Parser_Exception); - } - } - - public function testParseExampleWsdlAndCountResultElements() - { - // Constructor expects DOMDocument instance - $dom = $this->getWsdlExampleDom(); - $parser = new Zend_Soap_Wsdl_Parser($dom); - - $result = $parser->parse(); - - $this->assertEquals("Zend_Soap_Server_TestClass", $result->getName()); - $this->assertEquals(Zend_Soap_Wsdl_Parser::WSDL_11, $result->getVersion()); - $this->assertEquals(4, count($result->operations), "Number of operations does not match."); - $this->assertEquals(1, count($result->bindings), "Number of bindings does not match."); - $this->assertEquals(1, count($result->ports), "Number of ports does not match."); - $this->assertEquals(1, count($result->services), "Number of services does not match."); - $this->assertEquals(0, count($result->types), "Number of types does not match."); - $this->assertEquals(4, count($result->bindings->current()->operations), "Number of operations in the bindings collection does not match."); - $this->assertEquals(4, count($result->ports->current()->operations), "Number of operations in the ports collection does not match."); - } - - public function testParseExampleWsdlAndCheckMatchingNames() - { - // Constructor expects DOMDocument instance - $dom = $this->getWsdlExampleDom(); - $parser = new Zend_Soap_Wsdl_Parser($dom); - - $result = $parser->parse(); - - foreach($result->operations AS $operation) { - $this->assertContains($operation->getName(), array("testFunc1", "testFunc2", "testFunc3", "testFunc4")); - } - foreach($result->bindings AS $binding) { - $this->assertEquals("Zend_Soap_Server_TestClassBinding", $binding->getName()); - } - foreach($result->ports AS $port) { - $this->assertEquals("Zend_Soap_Server_TestClassPort", $port->getName()); - } - foreach($result->services AS $service) { - $this->assertEquals("Zend_Soap_Server_TestClassService", $service->getName()); - } - } - - public function testParseExampleWsdlWithDocumentationBlocks() - { - $dom = new DOMDocument(); - $dom->loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_documentation.wsdl")); - - $parser = new Zend_Soap_Wsdl_Parser($dom); - $result = $parser->parse(); - } -} diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index b93ddfdd..a8c97638 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -430,6 +430,11 @@ class Zend_Soap_AutoDiscover_Recursion * @var Zend_Soap_AutoDiscover_Recursion */ public $recursion; + + /** + * @return Zend_Soap_AutoDiscover_Recursion + */ + public function create() {} } /** From 667a0983343790ed8b51ac68df8604cc05248a77 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 May 2010 07:12:00 +0000 Subject: [PATCH 041/123] [ZF-9816] Zend_Soap_Server : mistake on spelling of the option features git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22222 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Server.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Server.php b/src/Server.php index 469192c3..bdd7f765 100644 --- a/src/Server.php +++ b/src/Server.php @@ -210,6 +210,7 @@ public function setOptions($options) $this->setWsdl($value); break; case 'featues': + case 'features': $this->setSoapFeatures($value); break; case 'cache_wsdl': From 325010ef001b01e155c555e226668e2952523a6f Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 May 2010 08:06:47 +0000 Subject: [PATCH 042/123] [ZF-9816] Zend_Soap_Server : mistake on spelling of the option features (test and trigger_error) git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22223 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Server.php | 1 + test/ServerTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Server.php b/src/Server.php index bdd7f765..db9ccdd2 100644 --- a/src/Server.php +++ b/src/Server.php @@ -210,6 +210,7 @@ public function setOptions($options) $this->setWsdl($value); break; case 'featues': + trigger_error(__METHOD__ . ': the option "featues" is deprecated as of 1.10.x and will be removed with 2.0.0; use "features" instead', E_USER_NOTICE); case 'features': $this->setSoapFeatures($value); break; diff --git a/test/ServerTest.php b/test/ServerTest.php index 4e28f77b..2ccefd8e 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -88,6 +88,21 @@ public function testSetOptionsViaSecondConstructorArgument() $this->assertTrue($server->getOptions() == $options); } + /** + * @group ZF-9816 + */ + public function testSetOptionsWithFeaturesOption() + { + $server = new Zend_Soap_Server(null, array( + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS + )); + + $this->assertEquals( + SOAP_SINGLE_ELEMENT_ARRAYS, + $server->getSoapFeatures() + ); + } + public function testSetWsdlViaOptionsArrayIsPossible() { $server = new Zend_Soap_Server(); From 75d8d5555b565fe9cbfa3eea6fa33f87700f78ca Mon Sep 17 00:00:00 2001 From: Alexander Veremyev Date: Wed, 26 May 2010 19:02:13 +0400 Subject: [PATCH 043/123] Zend_Soap to namespaces conversion --- src/{ => AutoDiscover}/AutoDiscover.php | 114 +++++---- src/AutoDiscover/Exception.php | 9 +- src/{ => Client}/Client.php | 184 +++++++------- src/Client/Common.php | 6 +- src/Client/DotNet.php | 17 +- src/Client/Exception.php | 9 +- src/Client/Local.php | 25 +- src/Server/Exception.php | 9 +- src/{ => Server}/Server.php | 140 ++++++----- src/{Wsdl => WSDL}/Exception.php | 15 +- .../Strategy/AbstractStrategy.php} | 27 +- src/{Wsdl => WSDL}/Strategy/AnyType.php | 19 +- .../Strategy/ArrayOfTypeComplex.php | 52 ++-- .../Strategy/ArrayOfTypeSequence.php | 25 +- src/{Wsdl => WSDL}/Strategy/Composite.php | 68 ++--- .../Strategy/DefaultComplexType.php | 25 +- .../Strategy/StrategyInterface.php} | 17 +- src/{Wsdl.php => WSDL/WSDL.php} | 72 +++--- test/AutoDiscover/OnlineTest.php | 15 +- test/AutoDiscoverTest.php | 140 +++++------ test/ClientTest.php | 77 +++--- test/ServerTest.php | 217 ++++++++-------- test/WSDL/ArrayOfTypeComplexStrategyTest.php | 233 ++++++++++++++++++ .../ArrayOfTypeSequenceStrategyTest.php | 37 +-- test/WSDL/CompositeStrategyTest.php | 147 +++++++++++ .../{Wsdl => WSDL}/DefaultComplexTypeTest.php | 25 +- test/{Wsdl => WSDL}/ElementTest.php | 124 +++++----- test/{Wsdl => WSDL}/ParserTest.php | 107 ++++---- test/{WsdlTest.php => WSDLTest.php} | 161 ++++++------ test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 227 ----------------- test/Wsdl/CompositeStrategyTest.php | 140 ----------- test/_files/commontypes.php | 77 +++--- test/_files/fulltests/server1.php | 28 ++- test/_files/fulltests/server2.php | 18 +- 34 files changed, 1383 insertions(+), 1223 deletions(-) rename src/{ => AutoDiscover}/AutoDiscover.php (82%) rename src/{ => Client}/Client.php (81%) rename src/{ => Server}/Server.php (84%) rename src/{Wsdl => WSDL}/Exception.php (82%) rename src/{Wsdl/Strategy/Abstract.php => WSDL/Strategy/AbstractStrategy.php} (68%) rename src/{Wsdl => WSDL}/Strategy/AnyType.php (77%) rename src/{Wsdl => WSDL}/Strategy/ArrayOfTypeComplex.php (70%) rename src/{Wsdl => WSDL}/Strategy/ArrayOfTypeSequence.php (89%) rename src/{Wsdl => WSDL}/Strategy/Composite.php (66%) rename src/{Wsdl => WSDL}/Strategy/DefaultComplexType.php (81%) rename src/{Wsdl/Strategy/Interface.php => WSDL/Strategy/StrategyInterface.php} (83%) rename src/{Wsdl.php => WSDL/WSDL.php} (91%) create mode 100644 test/WSDL/ArrayOfTypeComplexStrategyTest.php rename test/{Wsdl => WSDL}/ArrayOfTypeSequenceStrategyTest.php (73%) create mode 100644 test/WSDL/CompositeStrategyTest.php rename test/{Wsdl => WSDL}/DefaultComplexTypeTest.php (67%) rename test/{Wsdl => WSDL}/ElementTest.php (52%) rename test/{Wsdl => WSDL}/ParserTest.php (59%) rename test/{WsdlTest.php => WSDLTest.php} (85%) delete mode 100644 test/Wsdl/ArrayOfTypeComplexStrategyTest.php delete mode 100644 test/Wsdl/CompositeStrategyTest.php diff --git a/src/AutoDiscover.php b/src/AutoDiscover/AutoDiscover.php similarity index 82% rename from src/AutoDiscover.php rename to src/AutoDiscover/AutoDiscover.php index 6d11f917..b3f1b03b 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover/AutoDiscover.php @@ -21,27 +21,34 @@ */ /** - * Zend_Soap_AutoDiscover + * @namespace + */ +namespace Zend\Soap\AutoDiscover; +use Zend\URI; +use Zend\Soap\WSDL; + +/** + * \Zend\Soap\AutoDiscover\AutoDiscover * - * @uses Zend_Server_Abstract - * @uses Zend_Server_Interface - * @uses Zend_Server_Reflection - * @uses Zend_Soap_AutoDiscover_Exception - * @uses Zend_Soap_Wsdl - * @uses Zend_Uri + * @uses \Zend\Server\AbstractServer + * @uses \Zend\Server\ServerInterface + * @uses \Zend\Server\Reflection\Reflection + * @uses \Zend\Soap\AutoDiscover\Exception + * @uses \Zend\Soap\WSDL\WSDL + * @uses \Zend\URI\URI * @category Zend * @package Zend_Soap * @subpackage AutoDiscover */ -class Zend_Soap_AutoDiscover implements Zend_Server_Interface +class AutoDiscover implements \Zend\Server\ServerInterface { /** - * @var Zend_Soap_Wsdl + * @var \Zend\Soap\WSDL\WSDL */ protected $_wsdl = null; /** - * @var Zend_Server_Reflection + * @var \Zend\Server\Reflection\Reflection */ protected $_reflection = null; @@ -81,18 +88,18 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface * * @var string */ - protected $_wsdlClass = 'Zend_Soap_Wsdl'; + protected $_wsdlClass = '\Zend\Soap\WSDL\WSDL'; /** * Constructor * - * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy - * @param string|Zend_Uri $uri + * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @param string|\Zend\URI\URI $uri * @param string $wsdlClass */ public function __construct($strategy = true, $uri=null, $wsdlClass=null) { - $this->_reflection = new Zend_Server_Reflection(); + $this->_reflection = new \Zend\Server\Reflection\Reflection(); $this->setComplexTypeStrategy($strategy); if($uri !== null) { @@ -100,27 +107,28 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null) } if($wsdlClass !== null) { - $this->setWsdlClass($wsdlClass); + $this->setWSDLClass($wsdlClass); } } /** * Set the location at which the WSDL file will be availabe. * - * @see Zend_Soap_Exception - * @throws Zend_Soap_AutoDiscover_Exception - * @param Zend_Uri|string $uri - * @return Zend_Soap_AutoDiscover + * @throws \Zend\Soap\AutoDiscover\Exception + * @param \Zend\URI\URI|string $uri + * @return \Zend\Soap\AutoDiscover\AutoDiscover */ public function setUri($uri) { - if(!is_string($uri) && !($uri instanceof Zend_Uri)) { - throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance."); + if(!is_string($uri) && !($uri instanceof URI\URI)) { + throw new Exception( + 'No uri given to \Zend\Soap\AutoDiscover\AutoDiscover::setUri as string or \Zend\URI\URI instance.' + ); } $this->_uri = $uri; // change uri in WSDL file also if existant - if($this->_wsdl instanceof Zend_Soap_Wsdl) { + if($this->_wsdl instanceof WSDL\WSDL) { $this->_wsdl->setUri($uri); } @@ -130,7 +138,7 @@ public function setUri($uri) /** * Return the current Uri that the SOAP WSDL Service will be located at. * - * @return Zend_Uri + * @return \Zend\URI\URI */ public function getUri() { @@ -140,7 +148,7 @@ public function getUri() $schema = $this->getSchema(); $host = $this->getHostName(); $scriptName = $this->getRequestUriWithoutParameters(); - $uri = Zend_Uri::factory($schema . '://' . $host . $scriptName); + $uri = new URI\URL($schema . '://' . $host . $scriptName); $this->setUri($uri); } return $uri; @@ -149,17 +157,16 @@ public function getUri() /** * Set the name of the WSDL handling class. * - * @see Zend_Soap_Exception - * @see Zend_Soap_Exception - * @throws Zend_Soap_AutoDiscover_Exception + * @throws \Zend\Soap\AutoDiscover\Exception * @param string $wsdlClass - * @return Zend_Soap_AutoDiscover + * @return \Zend\Soap\AutoDiscover\AutoDiscover */ - public function setWsdlClass($wsdlClass) + public function setWSDLClass($wsdlClass) { - if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend_Soap_Wsdl')) { - require_once "Zend/Soap/AutoDiscover/Exception.php"; - throw new Zend_Soap_AutoDiscover_Exception("No Zend_Soap_Wsdl subclass given to Zend_Soap_AutoDiscover::setWsdlClass as string."); + if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, '\Zend\Soap\WSDL\WSDL')) { + throw new Exception( + 'No \Zend\Soap\WSDL\WSDL subclass given to \Zend\Soap\AutoDiscover\AutoDiscover::setWSDLClass as string.' + ); } $this->_wsdlClass = $wsdlClass; @@ -171,7 +178,7 @@ public function setWsdlClass($wsdlClass) * * @return string */ - public function getWsdlClass() + public function getWSDLClass() { return $this->_wsdlClass; } @@ -182,14 +189,13 @@ public function getWsdlClass() * By default the options are set to 'use' => 'encoded' and * 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/". * - * @see Zend_Soap_AutoDiscover_Exception * @param array $operationStyle - * @return Zend_Soap_AutoDiscover + * @return \Zend\Soap\AutoDiscover\AutoDiscover */ public function setOperationBodyStyle(array $operationStyle=array()) { if(!isset($operationStyle['use'])) { - throw new Zend_Soap_AutoDiscover_Exception("Key 'use' is required in Operation soap:body style."); + throw new Exception("Key 'use' is required in Operation soap:body style."); } $this->_operationBodyStyle = $operationStyle; return $this; @@ -201,7 +207,7 @@ public function setOperationBodyStyle(array $operationStyle=array()) * By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'. * * @param array $bindingStyle - * @return Zend_Soap_AutoDiscover + * @return \Zend\Soap\AutoDiscover\AutoDiscover */ public function setBindingStyle(array $bindingStyle=array()) { @@ -269,13 +275,13 @@ protected function getRequestUriWithoutParameters() /** * Set the strategy that handles functions and classes that are added AFTER this call. * - * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy - * @return Zend_Soap_AutoDiscover + * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @return \Zend\Soap\AutoDiscover\AutoDiscover */ public function setComplexTypeStrategy($strategy) { $this->_strategy = $strategy; - if($this->_wsdl instanceof Zend_Soap_Wsdl) { + if($this->_wsdl instanceof WSDL\WSDL) { $this->_wsdl->setComplexTypeStrategy($strategy); } @@ -304,7 +310,7 @@ public function setClass($class, $namespace = '', $argv = null) $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { - $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); + $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; } @@ -327,10 +333,10 @@ public function addFunction($function, $namespace = '') $uri = $this->getUri(); - if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) { + if (!($this->_wsdl instanceof WSDL\WSDL)) { $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; - $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy); + $wsdl = new WSDL\WSDL($name, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); @@ -346,7 +352,7 @@ public function addFunction($function, $namespace = '') foreach ($function as $func) { $method = $this->_reflection->reflectFunction($func); - $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); + $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; } @@ -354,13 +360,13 @@ public function addFunction($function, $namespace = '') /** * Add a function to the WSDL document. * - * @param $function Zend_Server_Reflection_Function_Abstract function to add - * @param $wsdl Zend_Soap_Wsdl WSDL document + * @param $function \Zend\Server\Reflection\AbstractFunction function to add + * @param $wsdl \Zend\Soap\WSDL\WSDL WSDL document * @param $port object wsdl:portType * @param $binding object wsdl:binding * @return void */ - protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) + protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) { $uri = $this->getUri(); @@ -375,7 +381,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } } if ($prototype === null) { - throw new Zend_Soap_AutoDiscover_Exception("No prototypes could be found for the '" . $function->getName() . "' function"); + throw new Exception("No prototypes could be found for the '" . $function->getName() . "' function"); } // Add the input message (parameters) @@ -469,7 +475,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) */ public function fault($fault = null, $code = null) { - throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + throw new Exception('Function has no use in AutoDiscover.'); } /** @@ -495,7 +501,7 @@ public function dump($filename) if($this->_wsdl !== null) { return $this->_wsdl->dump($filename); } else { - throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet."); + throw new Exception('Cannot dump autodiscovered contents, WSDL file has not been generated yet.'); } } @@ -507,7 +513,7 @@ public function toXml() if($this->_wsdl !== null) { return $this->_wsdl->toXml(); } else { - throw new Zend_Soap_AutoDiscover_Exception("Cannot return autodiscovered contents, WSDL file has not been generated yet."); + throw new Exception('Cannot return autodiscovered contents, WSDL file has not been generated yet.'); } } @@ -528,7 +534,7 @@ public function getFunctions() */ public function loadFunctions($definition) { - throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + throw new Exception('Function has no use in AutoDiscover.'); } /** @@ -538,7 +544,7 @@ public function loadFunctions($definition) */ public function setPersistence($mode) { - throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover."); + throw new Exception('Function has no use in AutoDiscover.'); } /** @@ -549,7 +555,7 @@ public function setPersistence($mode) */ public function getType($type) { - if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) { + if (!($this->_wsdl instanceof WSDL\WSDL)) { /** @todo Exception throwing may be more correct */ // WSDL is not defined yet, so we can't recognize type in context of current service diff --git a/src/AutoDiscover/Exception.php b/src/AutoDiscover/Exception.php index 2a43d493..5c752fff 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/AutoDiscover/Exception.php @@ -21,10 +21,15 @@ */ /** - * @uses Zend_Exception + * @namespace + */ +namespace Zend\Soap\AutoDiscover; + +/** + * @uses \Zend\Exception * @package Zend_Soap * @subpackage AutoDiscover */ -class Zend_Soap_AutoDiscover_Exception extends Zend_Exception +class Exception extends \Zend\Exception { } diff --git a/src/Client.php b/src/Client/Client.php similarity index 81% rename from src/Client.php rename to src/Client/Client.php index f8727719..7746c4e0 100644 --- a/src/Client.php +++ b/src/Client/Client.php @@ -21,19 +21,24 @@ */ /** - * Zend_Soap_Client + * @namespace + */ +namespace Zend\Soap\Client; + +/** + * \Zend\Soap\Client\Client * - * @uses Zend_Soap_Client_Common - * @uses Zend_Soap_Client_Exception - * @uses Zend_Soap_Client_Local - * @uses Zend_Soap_Server + * @uses \Zend\Soap\Client\Common + * @uses \Zend\Soap\Client\Exception + * @uses \Zend\Soap\Client\Local + * @uses \Zend\Soap\Server\Server * @category Zend * @package Zend_Soap * @subpackage Client * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Client +class Client { /** * Encoding @@ -81,7 +86,7 @@ class Zend_Soap_Client /** * WSDL used to access server - * It also defines Zend_Soap_Client working mode (WSDL vs non-WSDL) + * It also defines \Zend\Soap\Client\Client working mode (WSDL vs non-WSDL) * * @var string */ @@ -90,7 +95,7 @@ class Zend_Soap_Client /** * SoapClient object * - * @var SoapClient + * @var \SoapClient */ protected $_soapClient; @@ -133,15 +138,16 @@ class Zend_Soap_Client * * @param string $wsdl * @param array $options + * @throws \Zend\Soap\Client\Exception */ public function __construct($wsdl = null, $options = null) { if (!extension_loaded('soap')) { - throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.'); + throw new Exception('SOAP extension is not loaded.'); } if ($wsdl !== null) { - $this->setWsdl($wsdl); + $this->setWSDL($wsdl); } if ($options !== null) { $this->setOptions($options); @@ -152,9 +158,9 @@ public function __construct($wsdl = null, $options = null) * Set wsdl * * @param string $wsdl - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ - public function setWsdl($wsdl) + public function setWSDL($wsdl) { $this->_wsdl = $wsdl; $this->_soapClient = null; @@ -167,7 +173,7 @@ public function setWsdl($wsdl) * * @return string */ - public function getWsdl() + public function getWSDL() { return $this->_wsdl; } @@ -177,13 +183,13 @@ public function getWsdl() * * Allows setting options as an associative array of option => value pairs. * - * @param array|Zend_Config $options - * @return Zend_Soap_Client - * @throws Zend_SoapClient_Exception + * @param array|\Zend\Config\Config $options + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception */ public function setOptions($options) { - if($options instanceof Zend_Config) { + if($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } @@ -201,7 +207,7 @@ public function setOptions($options) $this->setSoapVersion($value); break; case 'wsdl': - $this->setWsdl($value); + $this->setWSDL($value); break; case 'uri': $this->setUri($value); @@ -249,7 +255,7 @@ public function setOptions($options) $this->setSoapFeatures($value); break; case 'cache_wsdl': - $this->setWsdlCache($value); + $this->setWSDLCache($value); break; case 'useragent': case 'userAgent': @@ -263,7 +269,7 @@ public function setOptions($options) // break; default: - throw new Zend_Soap_Client_Exception('Unknown SOAP client option'); + throw new Exception('Unknown SOAP client option'); break; } } @@ -283,7 +289,7 @@ public function getOptions() $options['classmap'] = $this->getClassmap(); $options['encoding'] = $this->getEncoding(); $options['soap_version'] = $this->getSoapVersion(); - $options['wsdl'] = $this->getWsdl(); + $options['wsdl'] = $this->getWSDL(); $options['uri'] = $this->getUri(); $options['location'] = $this->getLocation(); $options['style'] = $this->getStyle(); @@ -299,7 +305,7 @@ public function getOptions() $options['compression'] = $this->getCompressionOptions(); //$options['connection_timeout'] = $this->_connection_timeout; $options['stream_context'] = $this->getStreamContext(); - $options['cache_wsdl'] = $this->getWsdlCache(); + $options['cache_wsdl'] = $this->getWSDLCache(); $options['features'] = $this->getSoapFeatures(); $options['user_agent'] = $this->getUserAgent(); @@ -326,13 +332,13 @@ public function getOptions() * Set SOAP version * * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid soap version argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid soap version argument */ public function setSoapVersion($version) { if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { - throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.'); + throw new Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.'); } $this->_soapVersion = $version; @@ -355,14 +361,14 @@ public function getSoapVersion() * Set classmap * * @param array $classmap - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception for any invalid class in the class map + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception for any invalid class in the class map */ public function setClassmap(array $classmap) { foreach ($classmap as $type => $class) { if (!class_exists($class)) { - throw new Zend_Soap_Client_Exception('Invalid class in class map'); + throw new Exception('Invalid class in class map'); } } @@ -387,13 +393,13 @@ public function getClassmap() * Set encoding * * @param string $encoding - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid encoding argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid encoding argument */ public function setEncoding($encoding) { if (!is_string($encoding)) { - throw new Zend_Soap_Client_Exception('Invalid encoding specified'); + throw new Exception('Invalid encoding specified'); } $this->_encoding = $encoding; @@ -418,13 +424,13 @@ public function getEncoding() * * @param string $urn * @return true - * @throws Zend_Soap_Client_Exception on invalid URN + * @throws \Zend\Soap\Client\Exception on invalid URN */ public function validateUrn($urn) { $scheme = parse_url($urn, PHP_URL_SCHEME); if ($scheme === false || $scheme === null) { - throw new Zend_Soap_Client_Exception('Invalid URN'); + throw new Exception('Invalid URN'); } return true; @@ -437,8 +443,8 @@ public function validateUrn($urn) * URI in Web Service the target namespace * * @param string $uri - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid uri argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid uri argument */ public function setUri($uri) { @@ -466,8 +472,8 @@ public function getUri() * URI in Web Service the target namespace * * @param string $location - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid uri argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid uri argument */ public function setLocation($location) { @@ -493,13 +499,13 @@ public function getLocation() * Set request style * * @param int $style One of the SOAP_RPC or SOAP_DOCUMENT constants - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid style argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid style argument */ public function setStyle($style) { if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) { - throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); + throw new Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); } $this->_style = $style; @@ -523,13 +529,13 @@ public function getStyle() * Set message encoding method * * @param int $use One of the SOAP_ENCODED or SOAP_LITERAL constants - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid message encoding method argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid message encoding method argument */ public function setEncodingMethod($use) { if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) { - throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); + throw new Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); } $this->_use = $use; @@ -553,7 +559,7 @@ public function getEncodingMethod() * Set HTTP login * * @param string $login - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setHttpLogin($login) { @@ -578,7 +584,7 @@ public function getHttpLogin() * Set HTTP password * * @param string $password - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setHttpPassword($password) { @@ -603,7 +609,7 @@ public function getHttpPassword() * Set proxy host * * @param string $proxyHost - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setProxyHost($proxyHost) { @@ -628,7 +634,7 @@ public function getProxyHost() * Set proxy port * * @param int $proxyPort - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setProxyPort($proxyPort) { @@ -653,7 +659,7 @@ public function getProxyPort() * Set proxy login * * @param string $proxyLogin - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setProxyLogin($proxyLogin) { @@ -678,7 +684,7 @@ public function getProxyLogin() * Set proxy password * * @param string $proxyLogin - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setProxyPassword($proxyPassword) { @@ -693,13 +699,13 @@ public function setProxyPassword($proxyPassword) * Set HTTPS client certificate path * * @param string $localCert local certificate path - * @return Zend_Soap_Client - * @throws Zend_Soap_Client_Exception with invalid local certificate path argument + * @return \Zend\Soap\Client\Client + * @throws \Zend\Soap\Client\Exception with invalid local certificate path argument */ public function setHttpsCertificate($localCert) { if (!is_readable($localCert)) { - throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.'); + throw new Exception('Invalid HTTPS client certificate path.'); } $this->_local_cert = $localCert; @@ -723,7 +729,7 @@ public function getHttpsCertificate() * Set HTTPS client certificate passphrase * * @param string $passphrase - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setHttpsCertPassphrase($passphrase) { @@ -748,7 +754,7 @@ public function getHttpsCertPassphrase() * Set compression options * * @param int $compressionOptions - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setCompressionOptions($compressionOptions) { @@ -782,14 +788,12 @@ public function getProxyPassword() /** * Set Stream Context * - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setStreamContext($context) { if(!is_resource($context) || get_resource_type($context) !== "stream-context") { - throw new Zend_Soap_Client_Exception( - "Invalid stream context resource given." - ); + throw new Exception('Invalid stream context resource given.'); } $this->_stream_context = $context; @@ -810,7 +814,7 @@ public function getStreamContext() * Set the SOAP Feature options. * * @param string|int $feature - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setSoapFeatures($feature) { @@ -831,21 +835,21 @@ public function getSoapFeatures() } /** - * Set the SOAP Wsdl Caching Options + * Set the SOAP WSDL Caching Options * * @param string|int|boolean $caching - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ - public function setWsdlCache($options) + public function setWSDLCache($options) { $this->_cache_wsdl = $options; return $this; } /** - * Get current SOAP Wsdl Caching option + * Get current SOAP WSDL Caching option */ - public function getWsdlCache() + public function getWSDLCache() { return $this->_cache_wsdl; } @@ -854,7 +858,7 @@ public function getWsdlCache() * Set the string to use in User-Agent header * * @param string|null $userAgent - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setUserAgent($userAgent) { @@ -948,7 +952,7 @@ public function getLastMethod() * May be overridden in subclasses * * @internal - * @param Zend_Soap_Client_Common $client + * @param \Zend\Soap\Client\Common $client * @param string $request * @param string $location * @param string $action @@ -956,7 +960,7 @@ public function getLastMethod() * @param int $one_way * @return mixed */ - public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) + public function _doRequest(Common $client, $request, $location, $action, $version, $one_way = null) { // Perform request as is if ($one_way == null) { @@ -969,31 +973,31 @@ public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, /** * Initialize SOAP Client object * - * @throws Zend_Soap_Client_Exception + * @throws \Zend\Soap\Client\Exception */ protected function _initSoapClientObject() { - $wsdl = $this->getWsdl(); + $wsdl = $this->getWSDL(); $options = array_merge($this->getOptions(), array('trace' => true)); if ($wsdl == null) { if (!isset($options['location'])) { - throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.'); + throw new Exception('\'location\' parameter is required in non-WSDL mode.'); } if (!isset($options['uri'])) { - throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.'); + throw new Exception('\'uri\' parameter is required in non-WSDL mode.'); } } else { if (isset($options['use'])) { - throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.'); + throw new Exception('\'use\' parameter only works in non-WSDL mode.'); } if (isset($options['style'])) { - throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.'); + throw new Exception('\'style\' parameter only works in non-WSDL mode.'); } } unset($options['wsdl']); - $this->_soapClient = new Zend_Soap_Client_Common(array($this, '_doRequest'), $wsdl, $options); + $this->_soapClient = new Common(array($this, '_doRequest'), $wsdl, $options); } @@ -1028,9 +1032,9 @@ protected function _preProcessResult($result) * * @param SoapHeader $header * @param boolean $permanent - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ - public function addSoapInputHeader(SoapHeader $header, $permanent = false) + public function addSoapInputHeader(\SoapHeader $header, $permanent = false) { if ($permanent) { $this->_permanentSoapInputHeaders[] = $header; @@ -1044,7 +1048,7 @@ public function addSoapInputHeader(SoapHeader $header, $permanent = false) /** * Reset SOAP input headers * - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function resetSoapInputHeaders() { @@ -1079,10 +1083,10 @@ public function __call($name, $arguments) $soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders); $result = $soapClient->__soapCall($name, - $this->_preProcessArguments($arguments), - null, /* Options are already set to the SOAP client object */ - (count($soapHeaders) > 0)? $soapHeaders : null, - $this->_soapOutputHeaders); + $this->_preProcessArguments($arguments), + null, /* Options are already set to the SOAP client object */ + (count($soapHeaders) > 0)? $soapHeaders : null, + $this->_soapOutputHeaders); // Reset non-permanent input headers $this->_soapInputHeaders = array(); @@ -1095,12 +1099,12 @@ public function __call($name, $arguments) * Return a list of available functions * * @return array - * @throws Zend_Soap_Client_Exception + * @throws \Zend\Soap\Client\Exception */ public function getFunctions() { - if ($this->getWsdl() == null) { - throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.'); + if ($this->getWSDL() == null) { + throw new Exception('\'getFunctions\' method is available only in WSDL mode.'); } $soapClient = $this->getSoapClient(); @@ -1118,12 +1122,12 @@ public function getFunctions() * Return a list of SOAP types * * @return array - * @throws Zend_Soap_Client_Exception + * @throws \Zend\Soap\Client\Exception */ public function getTypes() { - if ($this->getWsdl() == null) { - throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.'); + if ($this->getWSDL() == null) { + throw new Exception('\'getTypes\' method is available only in WSDL mode.'); } $soapClient = $this->getSoapClient(); @@ -1133,9 +1137,9 @@ public function getTypes() /** * @param SoapClient $soapClient - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ - public function setSoapClient(SoapClient $soapClient) + public function setSoapClient(\SoapClient $soapClient) { $this->_soapClient = $soapClient; return $this; @@ -1155,7 +1159,7 @@ public function getSoapClient() /** * @param string $name * @param string $value - * @return Zend_Soap_Client + * @return \Zend\Soap\Client\Client */ public function setCookie($cookieName, $cookieValue=null) { diff --git a/src/Client/Common.php b/src/Client/Common.php index 21220e92..6e969bcf 100644 --- a/src/Client/Common.php +++ b/src/Client/Common.php @@ -20,6 +20,10 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace Zend\Soap\Client; if (extension_loaded('soap')) { @@ -29,7 +33,7 @@ * @package Zend_Soap * @subpackage Client */ -class Zend_Soap_Client_Common extends SoapClient +class Common extends \SoapClient { /** * doRequest() pre-processing method diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 87711674..079723ff 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -20,7 +20,10 @@ * @version $Id$ */ -if (extension_loaded('soap')) { +/** + * @namespace + */ +namespace Zend\Soap\Client; /** * Zend_Soap_Client_Local @@ -31,13 +34,13 @@ * Please leave your notes, compatiblity issues reports or * suggestions in fw-webservices@lists.zend.com or fw-general@lists.com * - * @uses Zend_Soap_Client - * @uses Zend_Soap_Client_Exception + * @uses \Zend\Soap\Client\Client + * @uses \Zend\Soap\Client\Exception * @category Zend * @package Zend_Soap * @subpackage Client */ -class Zend_Soap_Client_DotNet extends Zend_Soap_Client +class DotNet extends Client { /** * Constructor @@ -60,14 +63,14 @@ public function __construct($wsdl = null, $options = null) * My be overridden in descendant classes * * @param array $arguments - * @throws Zend_Soap_Client_Exception + * @throws \Zend\Soap\Client\Exception */ protected function _preProcessArguments($arguments) { if (count($arguments) > 1 || (count($arguments) == 1 && !is_array(reset($arguments))) ) { - throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); + throw new Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); } // Do nothing @@ -89,5 +92,3 @@ protected function _preProcessResult($result) } } - -} // end if (extension_loaded('soap') diff --git a/src/Client/Exception.php b/src/Client/Exception.php index 7b535c06..da720b12 100644 --- a/src/Client/Exception.php +++ b/src/Client/Exception.php @@ -20,7 +20,12 @@ */ /** - * @uses Zend_Exception + * @namespace + */ +namespace Zend\Soap\Client; + +/** + * @uses \Zend\Exception * @category Zend * @package Zend_Soap * @subpackage Client @@ -28,6 +33,6 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -class Zend_Soap_Client_Exception extends Zend_Exception +class Exception extends \Zend\Exception {} diff --git a/src/Client/Local.php b/src/Client/Local.php index e6bffc49..cb62a8c4 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -20,39 +20,42 @@ * @version $Id$ */ -if (extension_loaded('soap')) { +/** + * @namespace + */ +namespace Zend\Soap\Client; /** - * Zend_Soap_Client_Local + * \Zend\Soap\Client\Local * * Class is intended to be used as local SOAP client which works * with a provided Server object. * * Could be used for development or testing purposes. * - * @uses Zend_Soap_Client - * @uses Zend_Soap_Server + * @uses \Zend\Soap\Client\Client + * @uses \Zend\Soap\Server\Server * @category Zend * @package Zend_Soap * @subpackage Client */ -class Zend_Soap_Client_Local extends Zend_Soap_Client +class Local extends Client { /** * Server object * - * @var Zend_Soap_Server + * @var \Zend\Soap\Server\Server */ protected $_server; /** * Local client constructor * - * @param Zend_Soap_Server $server + * @param \Zend\Soap\Server\Server $server * @param string $wsdl * @param array $options */ - function __construct(Zend_Soap_Server $server, $wsdl, $options = null) + function __construct(\Zend\Soap\Server\Server $server, $wsdl, $options = null) { $this->_server = $server; @@ -66,7 +69,7 @@ function __construct(Zend_Soap_Server $server, $wsdl, $options = null) * Actual "do request" method. * * @internal - * @param Zend_Soap_Client_Common $client + * @param \Zend\Soap\Client\Common $client * @param string $request * @param string $location * @param string $action @@ -74,7 +77,7 @@ function __construct(Zend_Soap_Server $server, $wsdl, $options = null) * @param int $one_way * @return mixed */ - public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null) + public function _doRequest(Common $client, $request, $location, $action, $version, $one_way = null) { // Perform request as is ob_start(); @@ -85,5 +88,3 @@ public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, return $response; } } - -} // end if (extension_loaded('soap') diff --git a/src/Server/Exception.php b/src/Server/Exception.php index 03efb738..8bf94c20 100644 --- a/src/Server/Exception.php +++ b/src/Server/Exception.php @@ -20,7 +20,12 @@ */ /** - * @uses Zend_Exception + * @namespace + */ +namespace Zend\Soap\Server; + +/** + * @uses \Zend\Exception * @category Zend * @package Zend_Soap * @subpackage Server @@ -28,6 +33,6 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -class Zend_Soap_Server_Exception extends Zend_Exception +class Exception extends \Zend\Exception {} diff --git a/src/Server.php b/src/Server/Server.php similarity index 84% rename from src/Server.php rename to src/Server/Server.php index e90a2f22..ff119235 100644 --- a/src/Server.php +++ b/src/Server/Server.php @@ -19,14 +19,19 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ +/** + * @namespace + */ +namespace Zend\Soap\Server; + /** * Zend_Soap_Server * * @uses DOMDocument * @uses SoapFault * @uses SoapServer - * @uses Zend_Server_Interface - * @uses Zend_Soap_Server_Exception + * @uses \Zend\Server\ServerInterface + * @uses \Zend\Soap\Server\Exception * @category Zend * @package Zend_Soap * @subpackage Server @@ -34,7 +39,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -class Zend_Soap_Server implements Zend_Server_Interface +class Server implements \Zend\Server\ServerInterface { /** * Actor URI @@ -149,21 +154,22 @@ class Zend_Soap_Server implements Zend_Server_Interface * XML in response). Registers {@link handlePhpErrors()} as error handler * for E_USER_ERROR. * - * If $wsdl is provided, it is passed on to {@link setWsdl()}; if any + * If $wsdl is provided, it is passed on to {@link setWSDL()}; if any * options are specified, they are passed on to {@link setOptions()}. * * @param string $wsdl * @param array $options * @return void + * @throws \Zend\Soap\Server\Exception */ public function __construct($wsdl = null, array $options = null) { if (!extension_loaded('soap')) { - throw new Zend_Soap_Server_Exception('SOAP extension is not loaded.'); + throw new Exception('SOAP extension is not loaded.'); } if (null !== $wsdl) { - $this->setWsdl($wsdl); + $this->setWSDL($wsdl); } if (null !== $options) { @@ -176,12 +182,12 @@ public function __construct($wsdl = null, array $options = null) * * Allows setting options as an associative array of option => value pairs. * - * @param array|Zend_Config $options - * @return Zend_Soap_Server + * @param array|\Zend\Config\Config $options + * @return \Zend\Soap\Server\Server */ public function setOptions($options) { - if($options instanceof Zend_Config) { + if($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } @@ -205,13 +211,13 @@ public function setOptions($options) $this->setUri($value); break; case 'wsdl': - $this->setWsdl($value); + $this->setWSDL($value); break; case 'featues': $this->setSoapFeatures($value); break; case 'cache_wsdl': - $this->setWsdlCache($value); + $this->setWSDLCache($value); break; default: break; @@ -264,13 +270,13 @@ public function getOptions() * Set encoding * * @param string $encoding - * @return Zend_Soap_Server - * @throws Zend_Soap_Server_Exception with invalid encoding argument + * @return \Zend\Soap\Server\Server + * @throws \Zend\Soap\Server\Exception with invalid encoding argument */ public function setEncoding($encoding) { if (!is_string($encoding)) { - throw new Zend_Soap_Server_Exception('Invalid encoding specified'); + throw new Exception('Invalid encoding specified'); } $this->_encoding = $encoding; @@ -291,13 +297,13 @@ public function getEncoding() * Set SOAP version * * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants - * @return Zend_Soap_Server - * @throws Zend_Soap_Server_Exception with invalid soap version argument + * @return \Zend\Soap\Server\Server + * @throws \Zend\Soap\Server\Exception with invalid soap version argument */ public function setSoapVersion($version) { if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { - throw new Zend_Soap_Server_Exception('Invalid soap version specified'); + throw new Exception('Invalid soap version specified'); } $this->_soapVersion = $version; @@ -319,13 +325,13 @@ public function getSoapVersion() * * @param string $urn * @return true - * @throws Zend_Soap_Server_Exception on invalid URN + * @throws \Zend\Soap\Server\Exception on invalid URN */ public function validateUrn($urn) { $scheme = parse_url($urn, PHP_URL_SCHEME); if ($scheme === false || $scheme === null) { - throw new Zend_Soap_Server_Exception('Invalid URN'); + throw new Exception('Invalid URN'); } return true; @@ -337,7 +343,7 @@ public function validateUrn($urn) * Actor is the actor URI for the server. * * @param string $actor - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function setActor($actor) { @@ -362,8 +368,8 @@ public function getActor() * URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'. * * @param string $uri - * @return Zend_Soap_Server - * @throws Zend_Soap_Server_Exception with invalid uri argument + * @return \Zend\Soap\Server\Server + * @throws \Zend\Soap\Server\Exception with invalid uri argument */ public function setUri($uri) { @@ -386,17 +392,17 @@ public function getUri() * Set classmap * * @param array $classmap - * @return Zend_Soap_Server - * @throws Zend_Soap_Server_Exception for any invalid class in the class map + * @return \Zend\Soap\Server\Server + * @throws \Zend\Soap\Server\Exception for any invalid class in the class map */ public function setClassmap($classmap) { if (!is_array($classmap)) { - throw new Zend_Soap_Server_Exception('Classmap must be an array'); + throw new Exception('Classmap must be an array'); } foreach ($classmap as $type => $class) { if (!class_exists($class)) { - throw new Zend_Soap_Server_Exception('Invalid class in class map'); + throw new Exception('Invalid class in class map'); } } @@ -418,9 +424,9 @@ public function getClassmap() * Set wsdl * * @param string $wsdl URI or path to a WSDL - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ - public function setWsdl($wsdl) + public function setWSDL($wsdl) { $this->_wsdl = $wsdl; return $this; @@ -431,7 +437,7 @@ public function setWsdl($wsdl) * * @return string */ - public function getWsdl() + public function getWSDL() { return $this->_wsdl; } @@ -440,7 +446,7 @@ public function getWsdl() * Set the SOAP Feature options. * * @param string|int $feature - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function setSoapFeatures($feature) { @@ -459,21 +465,21 @@ public function getSoapFeatures() } /** - * Set the SOAP Wsdl Caching Options + * Set the SOAP WSDL Caching Options * * @param string|int|boolean $caching - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ - public function setWsdlCache($options) + public function setWSDLCache($options) { $this->_wsdlCache = $options; return $this; } /** - * Get current SOAP Wsdl Caching option + * Get current SOAP WSDL Caching option */ - public function getWsdlCache() + public function getWSDLCache() { return $this->_wsdlCache; } @@ -484,8 +490,8 @@ public function getWsdlCache() * @param array|string $function Function name, array of function names to attach, * or SOAP_FUNCTIONS_ALL to attach all functions * @param string $namespace Ignored - * @return Zend_Soap_Server - * @throws Zend_Soap_Server_Exception on invalid functions + * @return \Zend\Soap\Server\Server + * @throws \Zend\Soap\Server\Exception on invalid functions */ public function addFunction($function, $namespace = '') { @@ -499,7 +505,7 @@ public function addFunction($function, $namespace = '') if (is_string($func) && function_exists($func)) { $this->_functions[] = $func; } else { - throw new Zend_Soap_Server_Exception('One or more invalid functions specified in array'); + throw new Exception('One or more invalid functions specified in array'); } } $this->_functions = array_merge($this->_functions, $function); @@ -508,7 +514,7 @@ public function addFunction($function, $namespace = '') } elseif ($function == SOAP_FUNCTIONS_ALL) { $this->_functions = SOAP_FUNCTIONS_ALL; } else { - throw new Zend_Soap_Server_Exception('Invalid function specified'); + throw new Exception('Invalid function specified'); } if (is_array($this->_functions)) { @@ -527,22 +533,22 @@ public function addFunction($function, $namespace = '') * See {@link setObject()} to set preconfigured object instances as request handlers. * * @param string $class Class Name which executes SOAP Requests at endpoint. - * @return Zend_Soap_Server - * @throws Zend_Soap_Server_Exception if called more than once, or if class + * @return \Zend\Soap\Server\Server + * @throws \Zend\Soap\Server\Exception if called more than once, or if class * does not exist */ public function setClass($class, $namespace = '', $argv = null) { if (isset($this->_class)) { - throw new Zend_Soap_Server_Exception('A class has already been registered with this soap server instance'); + throw new Exception('A class has already been registered with this soap server instance'); } if (!is_string($class)) { - throw new Zend_Soap_Server_Exception('Invalid class argument (' . gettype($class) . ')'); + throw new Exception('Invalid class argument (' . gettype($class) . ')'); } if (!class_exists($class)) { - throw new Zend_Soap_Server_Exception('Class "' . $class . '" does not exist'); + throw new Exception('Class "' . $class . '" does not exist'); } $this->_class = $class; @@ -561,16 +567,16 @@ public function setClass($class, $namespace = '', $argv = null) * Accepts an instanciated object to use when handling requests. * * @param object $object - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function setObject($object) { if(!is_object($object)) { - throw new Zend_Soap_Server_Exception('Invalid object argument ('.gettype($object).')'); + throw new Exception('Invalid object argument ('.gettype($object).')'); } if(isset($this->_object)) { - throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance'); + throw new Exception('An object has already been registered with this soap server instance'); } $this->_object = $object; @@ -605,23 +611,23 @@ public function getFunctions() * * @param array $array * @return void - * @throws Zend_Soap_Server_Exception Unimplemented + * @throws \Zend\Soap\Server\Exception Unimplemented */ public function loadFunctions($definition) { - throw new Zend_Soap_Server_Exception('Unimplemented'); + throw new Exception('Unimplemented'); } /** * Set server persistence * * @param int $mode - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function setPersistence($mode) { if (!in_array($mode, array(SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST))) { - throw new Zend_Soap_Server_Exception('Invalid persistence mode specified'); + throw new Exception('Invalid persistence mode specified'); } $this->_persistence = $mode; @@ -631,7 +637,7 @@ public function setPersistence($mode) /** * Get server persistence * - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function getPersistence() { @@ -649,15 +655,15 @@ public function getPersistence() * - string; if so, verifies XML * * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ protected function _setRequest($request) { - if ($request instanceof DOMDocument) { + if ($request instanceof \DOMDocument) { $xml = $request->saveXML(); - } elseif ($request instanceof DOMNode) { + } elseif ($request instanceof \DOMNode) { $xml = $request->ownerDocument->saveXML(); - } elseif ($request instanceof SimpleXMLElement) { + } elseif ($request instanceof \SimpleXMLElement) { $xml = $request->asXML(); } elseif (is_object($request) || is_string($request)) { if (is_object($request)) { @@ -666,9 +672,9 @@ protected function _setRequest($request) $xml = $request; } - $dom = new DOMDocument(); + $dom = new \DOMDocument(); if(strlen($xml) == 0 || !$dom->loadXML($xml)) { - throw new Zend_Soap_Server_Exception('Invalid XML'); + throw new Exception('Invalid XML'); } } $this->_request = $xml; @@ -694,7 +700,7 @@ public function getLastRequest() * The response is always available via {@link getResponse()}. * * @param boolean $flag - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function setReturnResponse($flag) { @@ -734,7 +740,7 @@ public function getLastResponse() protected function _getSoap() { $options = $this->getOptions(); - $server = new SoapServer($this->_wsdl, $options); + $server = new \SoapServer($this->_wsdl, $options); if (!empty($this->_functions)) { $server->addFunction($this->_functions); @@ -782,26 +788,26 @@ public function handle($request = null) $request = file_get_contents('php://input'); } - // Set Zend_Soap_Server error handler + // Set \Zend\Soap\Server\Server error handler $displayErrorsOriginalState = $this->_initializeSoapErrorContext(); $setRequestException = null; try { $this->_setRequest($request); - } catch (Zend_Soap_Server_Exception $e) { + } catch (Exception $e) { $setRequestException = $e; } $soap = $this->_getSoap(); ob_start(); - if($setRequestException instanceof Exception) { + if($setRequestException instanceof \Exception) { // Send SOAP fault message if we've catched exception $soap->fault("Sender", $setRequestException->getMessage()); } else { try { $soap->handle($request); - } catch (Exception $e) { + } catch (\Exception $e) { $fault = $this->fault($e); $soap->fault($fault->faultcode, $fault->faultstring); } @@ -837,7 +843,7 @@ protected function _initializeSoapErrorContext() * Register a valid fault exception * * @param string|array $class Exception class or array of exception classes - * @return Zend_Soap_Server + * @return \Zend\Soap\Server\Server */ public function registerFaultException($class) { @@ -888,7 +894,7 @@ public function getFaultExceptions() */ public function fault($fault = null, $code = "Receiver") { - if ($fault instanceof Exception) { + if ($fault instanceof \Exception) { $class = get_class($fault); if (in_array($class, $this->_faultExceptions)) { $message = $fault->getMessage(); @@ -911,7 +917,7 @@ public function fault($fault = null, $code = "Receiver") $code = "Receiver"; } - return new SoapFault($code, $message); + return new \SoapFault($code, $message); } /** diff --git a/src/Wsdl/Exception.php b/src/WSDL/Exception.php similarity index 82% rename from src/Wsdl/Exception.php rename to src/WSDL/Exception.php index 819074c2..c7a13db2 100644 --- a/src/Wsdl/Exception.php +++ b/src/WSDL/Exception.php @@ -14,20 +14,25 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Zend_Soap_Wsdl_Exception + * @namespace + */ +namespace Zend\Soap\WSDL; + +/** + * Zend_Soap_WSDL_Exception * - * @uses Zend_Exception + * @uses \Zend\Exception * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Exception extends Zend_Exception { } +class Exception extends \Zend\Exception { } diff --git a/src/Wsdl/Strategy/Abstract.php b/src/WSDL/Strategy/AbstractStrategy.php similarity index 68% rename from src/Wsdl/Strategy/Abstract.php rename to src/WSDL/Strategy/AbstractStrategy.php index e4f07bd4..263d94a9 100644 --- a/src/Wsdl/Strategy/Abstract.php +++ b/src/WSDL/Strategy/AbstractStrategy.php @@ -14,46 +14,51 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Abstract class for Zend_Soap_Wsdl_Strategy. + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; + +/** + * Abstract class for Zend_Soap_WSDL_Strategy. * - * @uses Zend_Soap_Wsdl_Strategy_Interface + * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -abstract class Zend_Soap_Wsdl_Strategy_Abstract implements Zend_Soap_Wsdl_Strategy_Interface +abstract class AbstractStrategy implements StrategyInterface { /** * Context object * - * @var Zend_Soap_Wsdl + * @var \Zend\Soap\WSDL\WSDL */ protected $_context; /** - * Set the Zend_Soap_Wsdl Context object this strategy resides in. + * Set the Zend_Soap_WSDL Context object this strategy resides in. * - * @param Zend_Soap_Wsdl $context + * @param \Zend\Soap\WSDL\WSDL $context * @return void */ - public function setContext(Zend_Soap_Wsdl $context) + public function setContext(\Zend\Soap\WSDL\WSDL $context) { $this->_context = $context; } /** - * Return the current Zend_Soap_Wsdl context object + * Return the current Zend_Soap_WSDL context object * - * @return Zend_Soap_Wsdl + * @return \Zend\Soap\WSDL\WSDL */ public function getContext() { diff --git a/src/Wsdl/Strategy/AnyType.php b/src/WSDL/Strategy/AnyType.php similarity index 77% rename from src/Wsdl/Strategy/AnyType.php rename to src/WSDL/Strategy/AnyType.php index b03ccf04..90127b13 100644 --- a/src/Wsdl/Strategy/AnyType.php +++ b/src/WSDL/Strategy/AnyType.php @@ -14,30 +14,35 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Zend_Soap_Wsdl_Strategy_AnyType + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; + +/** + * Zend_Soap_WSDL_Strategy_AnyType * - * @uses Zend_Soap_Wsdl_Strategy_Interface + * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface +class AnyType implements StrategyInterface { /** * Not needed in this strategy. * - * @param Zend_Soap_Wsdl $context + * @param \Zend\Soap\WSDL\WSDL $context */ - public function setContext(Zend_Soap_Wsdl $context) + public function setContext(\Zend\Soap\WSDL\WSDL $context) { } diff --git a/src/Wsdl/Strategy/ArrayOfTypeComplex.php b/src/WSDL/Strategy/ArrayOfTypeComplex.php similarity index 70% rename from src/Wsdl/Strategy/ArrayOfTypeComplex.php rename to src/WSDL/Strategy/ArrayOfTypeComplex.php index 33f4d354..680a807b 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeComplex.php +++ b/src/WSDL/Strategy/ArrayOfTypeComplex.php @@ -14,24 +14,30 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap\WSDL; + +/** + * Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex * - * @uses Zend_Soap_Wsdl_Exception - * @uses Zend_Soap_Wsdl_Strategy_DefaultComplexType + * @uses \Zend\Soap\WSDL\Exception + * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_DefaultComplexType +class ArrayOfTypeComplex extends DefaultComplexType { protected $_inProcess = array(); @@ -44,25 +50,25 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy public function addComplexType($type) { if(in_array($type, $this->_inProcess)) { - throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itself."); + throw new WSDL\Exception("Infinite recursion, cannot nest '$type' into itself."); } $this->_inProcess[$type] = $type; $nestingLevel = $this->_getNestedCount($type); if($nestingLevel > 1) { - throw new Zend_Soap_Wsdl_Exception( - "ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ". - "one level. Use array object properties to return deep nested data. - "); + throw new WSDL\Exception( + 'ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ' + . 'one level. Use array object properties to return deep nested data.' + ); } $singularType = $this->_getSingularPhpType($type); if(!class_exists($singularType)) { - throw new Zend_Soap_Wsdl_Exception(sprintf( - "Cannot add a complex type %s that is not an object or where ". - "class could not be found in 'DefaultComplexType' strategy.", $type + throw new WSDL\Exception(sprintf( + 'Cannot add a complex type %s that is not an object or where ' + . 'class could not be found in \'DefaultComplexType\' strategy.', $type )); } @@ -79,7 +85,7 @@ public function addComplexType($type) } unset($this->_inProcess[$type]); - return "tns:".$xsdComplexTypeName; + return 'tns:' . $xsdComplexTypeName; } protected function _addArrayOfComplexType($singularType, $type) @@ -92,16 +98,16 @@ protected function _addArrayOfComplexType($singularType, $type) $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $xsdComplexTypeName); - $complexContent = $dom->createElement("xsd:complexContent"); + $complexContent = $dom->createElement('xsd:complexContent'); $complexType->appendChild($complexContent); - $xsdRestriction = $dom->createElement("xsd:restriction"); + $xsdRestriction = $dom->createElement('xsd:restriction'); $xsdRestriction->setAttribute('base', 'soap-enc:Array'); $complexContent->appendChild($xsdRestriction); - $xsdAttribute = $dom->createElement("xsd:attribute"); - $xsdAttribute->setAttribute("ref", "soap-enc:arrayType"); - $xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType)); + $xsdAttribute = $dom->createElement('xsd:attribute'); + $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType'); + $xsdAttribute->setAttribute('wsdl:arrayType', "tns:{$singularType}[]"); $xsdRestriction->appendChild($xsdAttribute); $this->getContext()->getSchema()->appendChild($complexType); @@ -113,7 +119,7 @@ protected function _addArrayOfComplexType($singularType, $type) protected function _getXsdComplexTypeName($type) { - return sprintf('ArrayOf%s', $type); + return 'ArrayOf' . $type; } /** @@ -124,7 +130,7 @@ protected function _getXsdComplexTypeName($type) */ protected function _getSingularPhpType($type) { - return str_replace("[]", "", $type); + return str_replace('[]', '', $type); } /** @@ -135,6 +141,6 @@ protected function _getSingularPhpType($type) */ protected function _getNestedCount($type) { - return substr_count($type, "[]"); + return substr_count($type, '[]'); } } diff --git a/src/Wsdl/Strategy/ArrayOfTypeSequence.php b/src/WSDL/Strategy/ArrayOfTypeSequence.php similarity index 89% rename from src/Wsdl/Strategy/ArrayOfTypeSequence.php rename to src/WSDL/Strategy/ArrayOfTypeSequence.php index f5b0c288..1cbb35d8 100644 --- a/src/Wsdl/Strategy/ArrayOfTypeSequence.php +++ b/src/WSDL/Strategy/ArrayOfTypeSequence.php @@ -20,16 +20,21 @@ */ /** - * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; + +/** + * Zend_Soap_WSDL_Strategy_ArrayOfTypeSequence * - * @uses Zend_Soap_Wsdl_Strategy_DefaultComplexType + * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_DefaultComplexType +class ArrayOfTypeSequence extends DefaultComplexType { /** * Add an unbounded ArrayOfType based on the xsd:sequence syntax if type[] is detected in return value doc comment. @@ -48,7 +53,7 @@ public function addComplexType($type) $complexTypeName = substr($this->_getTypeNameBasedOnNestingLevel($singularType, $i), 4); $childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1); - $this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName); + $this->_addElementFromWSDLAndChildTypes($complexTypeName, $childTypeName); } // adding the PHP type which is resolved to a nested XSD type. therefore add only once. $this->getContext()->addType($complexTypeName); @@ -76,7 +81,7 @@ protected function _getTypeNameBasedOnNestingLevel($singularType, $level) // This is not an Array anymore, return the xsd simple type return $singularType; } else { - $prefix = str_repeat("ArrayOf", $level); + $prefix = str_repeat('ArrayOf', $level); $xsdType = $this->_getStrippedXsdType($singularType); $arrayType = $prefix.$xsdType; return "tns:$arrayType"; @@ -97,13 +102,13 @@ protected function _getStrippedXsdType($singularType) /** * From a nested defintion with type[], get the singular xsd:type * - * @throws Zend_Soap_Wsdl_Exception When no xsd:simpletype can be detected. + * @throws \Zend\Soap\WSDL\Exception When no xsd:simpletype can be detected. * @param string $type * @return string */ protected function _getSingularType($type) { - $singulartype = $this->getContext()->getType(str_replace("[]", "", $type)); + $singulartype = $this->getContext()->getType(str_replace('[]', '', $type)); return $singulartype; } @@ -115,7 +120,7 @@ protected function _getSingularType($type) */ protected function _getNestedCount($type) { - return substr_count($type, "[]"); + return substr_count($type, '[]'); } /** @@ -125,7 +130,7 @@ protected function _getNestedCount($type) * @param string $childTypeName * @return void */ - protected function _addElementFromWsdlAndChildTypes($arrayType, $childTypeName) + protected function _addElementFromWSDLAndChildTypes($arrayType, $childTypeName) { if (!in_array($arrayType, $this->getContext()->getTypes())) { $dom = $this->getContext()->toDomDocument(); diff --git a/src/Wsdl/Strategy/Composite.php b/src/WSDL/Strategy/Composite.php similarity index 66% rename from src/Wsdl/Strategy/Composite.php rename to src/WSDL/Strategy/Composite.php index c4c31717..8818df57 100644 --- a/src/Wsdl/Strategy/Composite.php +++ b/src/WSDL/Strategy/Composite.php @@ -14,24 +14,30 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Zend_Soap_Wsdl_Strategy_Composite + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap\WSDL; + +/** + * Zend_Soap_WSDL_Strategy_Composite * - * @uses Zend_Soap_Wsdl_Exception - * @uses Zend_Soap_Wsdl_Strategy_Interface + * @uses \Zend\Soap\WSDL\Exception + * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface +class Composite implements StrategyInterface { /** * Typemap of Complex Type => Strategy pairs. @@ -43,25 +49,25 @@ class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Inter /** * Default Strategy of this composite * - * @var string|Zend_Soap_Wsdl_Strategy_Interface + * @var string|\Zend\Soap\WSDL\Strategy\StrategyInterface */ protected $_defaultStrategy; /** * Context WSDL file that this composite serves * - * @var Zend_Soap_Wsdl|null + * @var \Zend\Soap\WSDL\WSDL|null */ protected $_context; /** * Construct Composite WSDL Strategy. * - * @throws Zend_Soap_Wsdl_Exception + * @throws \Zend\Soap\WSDL\Exception * @param array $typeMap - * @param string|Zend_Soap_Wsdl_Strategy_Interface $defaultStrategy + * @param string|\Zend\Soap\WSDL\Strategy\StrategyInterface $defaultStrategy */ - public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_Wsdl_Strategy_DefaultComplexType") + public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_WSDL_Strategy_DefaultComplexType") { foreach($typeMap AS $type => $strategy) { $this->connectTypeToStrategy($type, $strategy); @@ -72,15 +78,15 @@ public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_ /** * Connect a complex type to a given strategy. * - * @throws Zend_Soap_Wsdl_Exception + * @throws \Zend\Soap\WSDL\Exception * @param string $type - * @param string|Zend_Soap_Wsdl_Strategy_Interface $strategy - * @return Zend_Soap_Wsdl_Strategy_Composite + * @param string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @return \Zend\Soap\WSDL\Strategy\Composite */ public function connectTypeToStrategy($type, $strategy) { if(!is_string($type)) { - throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map."); + throw new WSDL\Exception('Invalid type given to Composite Type Map.'); } $this->_typeMap[$type] = $strategy; return $this; @@ -89,9 +95,9 @@ public function connectTypeToStrategy($type, $strategy) /** * Return default strategy of this composite * - * @throws Zend_Soap_Wsdl_Exception + * @throws \Zend\Soap\WSDL\Exception * @param string $type - * @return Zend_Soap_Wsdl_Strategy_Interface + * @return \Zend\Soap\WSDL\Strategy\StrategyInterface */ public function getDefaultStrategy() { @@ -99,9 +105,9 @@ public function getDefaultStrategy() if(is_string($strategy) && class_exists($strategy)) { $strategy = new $strategy; } - if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { - throw new Zend_Soap_Wsdl_Exception( - "Default Strategy for Complex Types is not a valid strategy object." + if( !($strategy instanceof StrategyInterface) ) { + throw new WSDL\Exception( + 'Default Strategy for Complex Types is not a valid strategy object.' ); } $this->_defaultStrategy = $strategy; @@ -111,9 +117,9 @@ public function getDefaultStrategy() /** * Return specific strategy or the default strategy of this type. * - * @throws Zend_Soap_Wsdl_Exception + * @throws \Zend\Soap\WSDL\Exception * @param string $type - * @return Zend_Soap_Wsdl_Strategy_Interface + * @return \Zend\Soap\WSDL\Strategy\StrategyInterface */ public function getStrategyOfType($type) { @@ -124,9 +130,9 @@ public function getStrategyOfType($type) $strategy = new $strategy(); } - if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { - throw new Zend_Soap_Wsdl_Exception( - "Strategy for Complex Type '".$type."' is not a valid strategy object." + if( !($strategy instanceof StrategyInterface) ) { + throw new WSDL\Exception( + "Strategy for Complex Type '$type' is not a valid strategy object." ); } $this->_typeMap[$type] = $strategy; @@ -139,9 +145,9 @@ public function getStrategyOfType($type) /** * Method accepts the current WSDL context file. * - * @param Zend_Soap_Wsdl $context + * @param \Zend\Soap\WSDL\WSDL $context */ - public function setContext(Zend_Soap_Wsdl $context) + public function setContext(WSDL\WSDL $context) { $this->_context = $context; return $this; @@ -150,15 +156,15 @@ public function setContext(Zend_Soap_Wsdl $context) /** * Create a complex type based on a strategy * - * @throws Zend_Soap_Wsdl_Exception + * @throws \Zend\Soap\WSDL\Exception * @param string $type * @return string XSD type */ public function addComplexType($type) { - if(!($this->_context instanceof Zend_Soap_Wsdl) ) { - throw new Zend_Soap_Wsdl_Exception( - "Cannot add complex type '".$type."', no context is set for this composite strategy." + if(!($this->_context instanceof WSDL\WSDL) ) { + throw new WSDL\Exception( + "Cannot add complex type '$type', no context is set for this composite strategy." ); } diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/WSDL/Strategy/DefaultComplexType.php similarity index 81% rename from src/Wsdl/Strategy/DefaultComplexType.php rename to src/WSDL/Strategy/DefaultComplexType.php index 2042f881..76bce886 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/WSDL/Strategy/DefaultComplexType.php @@ -14,25 +14,30 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Zend_Soap_Wsdl_Strategy_DefaultComplexType + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; + +/** + * Zend_Soap_WSDL_Strategy_DefaultComplexType * * @uses ReflectionClass - * @uses Zend_Soap_Wsdl_Exception - * @uses Zend_Soap_Wsdl_Strategy_Abstract + * @uses \Zend\Soap\WSDL\Exception + * @uses \Zend\Soap\WSDL\Strategy\AbstractStrategy * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract +class DefaultComplexType extends AbstractStrategy { /** * Add a complex type by recursivly using all the class properties fetched via Reflection. @@ -43,14 +48,14 @@ class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy public function addComplexType($type) { if(!class_exists($type)) { - throw new Zend_Soap_Wsdl_Exception(sprintf( - "Cannot add a complex type %s that is not an object or where ". - "class could not be found in 'DefaultComplexType' strategy.", $type + throw new \Zend\Soap\WSDL\Exception(sprintf( + 'Cannot add a complex type %s that is not an object or where ' + . 'class could not be found in \'DefaultComplexType\' strategy.', $type )); } $dom = $this->getContext()->toDomDocument(); - $class = new ReflectionClass($type); + $class = new \ReflectionClass($type); $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $type); diff --git a/src/Wsdl/Strategy/Interface.php b/src/WSDL/Strategy/StrategyInterface.php similarity index 83% rename from src/Wsdl/Strategy/Interface.php rename to src/WSDL/Strategy/StrategyInterface.php index 456bc6ea..9e0036e4 100644 --- a/src/Wsdl/Strategy/Interface.php +++ b/src/WSDL/Strategy/StrategyInterface.php @@ -14,29 +14,34 @@ * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** - * Interface for Zend_Soap_Wsdl_Strategy. + * @namespace + */ +namespace Zend\Soap\WSDL\Strategy; + +/** + * Interface for Zend_Soap_WSDL_Strategy. * * @category Zend * @package Zend_Soap - * @subpackage Wsdl + * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -interface Zend_Soap_Wsdl_Strategy_Interface +interface StrategyInterface { /** * Method accepts the current WSDL context file. * * @param $context */ - public function setContext(Zend_Soap_Wsdl $context); + public function setContext(\Zend\Soap\WSDL\WSDL $context); /** * Create a complex type based on a strategy @@ -45,4 +50,4 @@ public function setContext(Zend_Soap_Wsdl $context); * @return string XSD type */ public function addComplexType($type); -} \ No newline at end of file +} diff --git a/src/Wsdl.php b/src/WSDL/WSDL.php similarity index 91% rename from src/Wsdl.php rename to src/WSDL/WSDL.php index 8f2e2c13..b0788d0e 100644 --- a/src/Wsdl.php +++ b/src/WSDL/WSDL.php @@ -20,19 +20,27 @@ */ /** - * Zend_Soap_Wsdl + * @namespace + */ +namespace Zend\Soap\WSDL; +use Zend\URI; + +/** + * \Zend\Soap\WSDL\WSDL * * @uses DOMDocument - * @uses Zend_Server_Exception - * @uses Zend_Soap_Wsdl_Exception - * @uses Zend_Soap_Wsdl_Strategy_Abstract - * @uses Zend_Soap_Wsdl_Strategy_AnyType - * @uses Zend_Soap_Wsdl_Strategy_DefaultComplexType - * @uses Zend_Soap_Wsdl_Strategy_Interface + * @uses \Zend\Server\Exception + * @uses \Zend\Soap\WSDL\Exception + * @uses \Zend\Soap\WSDL\Strategy\AbstractStrategy + * @uses \Zend\Soap\WSDL\Strategy\AnyType + * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType + * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface * @category Zend * @package Zend_Soap + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl +class WSDL { /** * @var object DomDocument Instance @@ -71,12 +79,12 @@ class Zend_Soap_Wsdl * Constructor * * @param string $name Name of the Web Service being Described - * @param string $uri URI where the WSDL will be available - * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @param string|\Zend\URI\URL $uri URI where the WSDL will be available + * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy */ public function __construct($name, $uri, $strategy = true) { - if ($uri instanceof Zend_Uri_Http) { + if ($uri instanceof URI\URL) { $uri = $uri->getUri(); } $this->_uri = $uri; @@ -93,9 +101,9 @@ public function __construct($name, $uri, $strategy = true) xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>"; - $this->_dom = new DOMDocument(); + $this->_dom = new \DOMDocument(); if (!$this->_dom->loadXML($wsdl)) { - throw new Zend_Server_Exception('Unable to create DomDocument'); + throw new Exception('Unable to create DomDocument'); } else { $this->_wsdl = $this->_dom->documentElement; } @@ -106,12 +114,12 @@ public function __construct($name, $uri, $strategy = true) /** * Set a new uri for this WSDL * - * @param string|Zend_Uri_Http $uri - * @return Zend_Server_Wsdl + * @param string|\Zend\URI\URL $uri + * @return \Zend\Server\WSDL\WSDL */ public function setUri($uri) { - if ($uri instanceof Zend_Uri_Http) { + if ($uri instanceof URI\URL) { $uri = $uri->getUri(); } $oldUri = $this->_uri; @@ -121,7 +129,7 @@ public function setUri($uri) // @todo: This is the worst hack ever, but its needed due to design and non BC issues of WSDL generation $xml = $this->_dom->saveXML(); $xml = str_replace($oldUri, $uri, $xml); - $this->_dom = new DOMDocument(); + $this->_dom = new \DOMDocument(); $this->_dom->loadXML($xml); } @@ -132,27 +140,27 @@ public function setUri($uri) * Set a strategy for complex type detection and handling * * @todo Boolean is for backwards compability with extractComplexType object var. Remove it in later versions. - * @param boolean|string|Zend_Soap_Wsdl_Strategy_Interface $strategy - * @return Zend_Soap_Wsdl + * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @return \Zend\Soap\WSDL\WSDL */ public function setComplexTypeStrategy($strategy) { if($strategy === true) { - $strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType(); + $strategy = new Strategy\DefaultComplexType(); } else if($strategy === false) { - $strategy = new Zend_Soap_Wsdl_Strategy_AnyType(); + $strategy = new Strategy\AnyType(); } else if(is_string($strategy)) { if(class_exists($strategy)) { $strategy = new $strategy(); } else { - throw new Zend_Soap_Wsdl_Exception( + throw new Exception( sprintf("Strategy with name '%s does not exist.", $strategy )); } } - if(!($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface)) { - throw new Zend_Soap_Wsdl_Exception("Set a strategy that is not of type 'Zend_Soap_Wsdl_Strategy_Interface'"); + if(!($strategy instanceof Strategy\StrategyInterface)) { + throw new Exception("Set a strategy that is not of type 'Zend_Soap_WSDL_Strategy_Interface'"); } $this->_strategy = $strategy; return $this; @@ -161,7 +169,7 @@ public function setComplexTypeStrategy($strategy) /** * Get the current complex type strategy * - * @return Zend_Soap_Wsdl_Strategy_Interface + * @return \Zend\Soap\WSDL\Strategy\StrategyInterface */ public function getComplexTypeStrategy() { @@ -353,7 +361,7 @@ public function addSoapBinding($binding, $style = 'document', $transport = 'http */ public function addSoapOperation($binding, $soap_action) { - if ($soap_action instanceof Zend_Uri_Http) { + if ($soap_action instanceof URI\URL) { $soap_action = $soap_action->getUri(); } $soap_operation = $this->_dom->createElement('soap:operation'); @@ -375,7 +383,7 @@ public function addSoapOperation($binding, $soap_action) */ public function addService($name, $port_name, $binding, $location) { - if ($location instanceof Zend_Uri_Http) { + if ($location instanceof URI\URL) { $location = $location->getUri(); } $service = $this->_dom->createElement('service'); @@ -435,10 +443,10 @@ public function addDocumentation($input_node, $documentation) */ public function addTypes($types) { - if ($types instanceof DomDocument) { + if ($types instanceof \DomDocument) { $dom = $this->_dom->importNode($types->documentElement); $this->_wsdl->appendChild($types->documentElement); - } elseif ($types instanceof DomNode || $types instanceof DomElement || $types instanceof DomDocumentFragment ) { + } elseif ($types instanceof \DomNode || $types instanceof \DomElement || $types instanceof \DomDocumentFragment ) { $dom = $this->_dom->importNode($types); $this->_wsdl->appendChild($dom); } @@ -448,7 +456,7 @@ public function addTypes($types) * Add a complex type name that is part of this WSDL and can be used in signatures. * * @param string $type - * @return Zend_Soap_Wsdl + * @return \Zend\Soap\WSDL\WSDL */ public function addType($type) { @@ -562,7 +570,7 @@ public function getType($type) /** * This function makes sure a complex types section and schema additions are set. * - * @return Zend_Soap_Wsdl + * @return \Zend\Soap\WSDL\WSDL */ public function addSchemaTypeSection() { @@ -604,7 +612,7 @@ public function addComplexType($type) private function _parseElement($element) { if (!is_array($element)) { - throw new Zend_Soap_Wsdl_Exception("The 'element' parameter needs to be an associative array."); + throw new Exception("The 'element' parameter needs to be an associative array."); } $elementXml = $this->_dom->createElement('xsd:element'); diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index 5daa6e00..e922ad13 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -20,6 +20,11 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\AutoDiscover; +use Zend\Soap\Client; /** Zend_Soap_Server */ @@ -31,7 +36,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ -class Zend_Soap_AutoDiscover_OnlineTest extends PHPUnit_Framework_TestCase +class OnlineTest extends \PHPUnit_Framework_TestCase { protected $baseuri; @@ -47,11 +52,11 @@ public function testNestedObjectArrayResponse() { $wsdl = $this->baseuri."/server1.php?wsdl"; - $b = new Zend_Soap_Wsdl_ComplexTypeB(); + $b = new \ZendTest\Soap\_files\ComplexTypeB(); $b->bar = "test"; $b->foo = "test"; - $client = new Zend_Soap_Client($wsdl); + $client = new Client\Client($wsdl); $ret = $client->request($b); $this->assertTrue( is_array($ret) ); @@ -72,10 +77,10 @@ public function testObjectResponse() { $wsdl = $this->baseuri."/server2.php?wsdl"; - $client = new Zend_Soap_Client($wsdl); + $client = new Client\Client($wsdl); $ret = $client->request("test", "test"); - $this->assertTrue( ($ret instanceof stdClass) ); + $this->assertTrue( ($ret instanceof \stdClass) ); $this->assertEquals("test", $ret->foo); $this->assertEquals("test", $ret->bar); } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 148a73b8..24865fbb 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -20,16 +20,16 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap; +use Zend\Soap\AutoDiscover; /** PHPUnit Test Case */ -/** Zend_Soap_AutoDiscover */ - -/** Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex */ - -/** Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence */ - /** Include Common TestTypes */ +require_once '_files/commontypes.php'; /** * Test cases for Zend_Soap_AutoDiscover @@ -41,7 +41,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ -class Zend_Soap_AutoDiscoverTest extends PHPUnit_Framework_TestCase +class AutoDiscoverTest extends \PHPUnit_Framework_TestCase { public function setUp() { @@ -56,7 +56,7 @@ public function setUp() $_SERVER['HTTPS'] = "off"; } - protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) + protected function sanitizeWSDLXmlOutputForOsCompability($xmlstring) { $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring); $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); @@ -67,9 +67,9 @@ function testSetClass() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); - $server->setClass('Zend_Soap_AutoDiscover_Test'); - $dom = new DOMDocument(); + $server = new AutoDiscover\AutoDiscover(); + $server->setClass('\ZendTest\Soap\_files\Test'); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); @@ -146,7 +146,7 @@ function testSetClass() . ''; $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/setclass.wsdl'); @@ -156,11 +156,11 @@ function testSetClassWithDifferentStyles() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->setClass('Zend_Soap_AutoDiscover_Test'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); @@ -303,7 +303,7 @@ function testSetClassWithDifferentStyles() . ''; $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/setclass.wsdl'); @@ -316,18 +316,18 @@ function testSetClassWithResponseReturnPartCompabilityMode() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->setClass('Zend_Soap_AutoDiscover_Test'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); - $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); unlink(dirname(__FILE__).'/_files/setclass.wsdl'); } @@ -337,9 +337,9 @@ function testAddFunctionSimple() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); @@ -370,7 +370,7 @@ function testAddFunctionSimple() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); @@ -380,11 +380,11 @@ function testAddFunctionSimpleWithDifferentStyle() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); @@ -420,7 +420,7 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); @@ -433,9 +433,9 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); @@ -444,7 +444,7 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; - $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()); + $wsdl = $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()); $this->assertContains('', $wsdl); $this->assertNotContains('assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -456,7 +456,7 @@ function testAddFunctionMultiple() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc2'); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc3'); @@ -466,7 +466,7 @@ function testAddFunctionMultiple() $server->addFunction('Zend_Soap_AutoDiscover_TestFunc7'); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc9'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); @@ -552,7 +552,7 @@ function testAddFunctionMultiple() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); + $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -568,7 +568,7 @@ public function testUseHttpsSchemaIfAccessedThroughHttps() $_SERVER['HTTPS'] = "on"; $httpsScriptUri = 'https://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); ob_start(); @@ -581,11 +581,11 @@ public function testUseHttpsSchemaIfAccessedThroughHttps() /** * @group ZF-4117 */ - public function testChangeWsdlUriInConstructor() + public function testChangeWSDLUriInConstructor() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(true, "http://example.com/service.php"); + $server = new AutoDiscover\AutoDiscover(true, "http://example.com/service.php"); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); ob_start(); @@ -599,11 +599,11 @@ public function testChangeWsdlUriInConstructor() /** * @group ZF-4117 */ - public function testChangeWsdlUriViaSetUri() + public function testChangeWSDLUriViaSetUri() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(true); + $server = new AutoDiscover\AutoDiscover(true); $server->setUri("http://example.com/service.php"); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); @@ -617,11 +617,11 @@ public function testChangeWsdlUriViaSetUri() public function testSetNonStringNonZendUriUriThrowsException() { - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); try { $server->setUri(array("bogus")); $this->fail(); - } catch(Zend_Soap_AutoDiscover_Exception $e) { + } catch(AutoDiscover\Exception $e) { } } @@ -629,11 +629,11 @@ public function testSetNonStringNonZendUriUriThrowsException() /** * @group ZF-4117 */ - public function testChangingWsdlUriAfterGenerationIsPossible() + public function testChangingWSDLUriAfterGenerationIsPossible() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(true); + $server = new AutoDiscover\AutoDiscover(true); $server->setUri("http://example.com/service.php"); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); @@ -660,11 +660,11 @@ public function testChangingWsdlUriAfterGenerationIsPossible() * @group ZF-4125 * */ - public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() + public function testUsingClassWithMultipleMethodPrototypesProducesValidWSDL() { $scriptUri = 'http://localhost/my_script.php'; - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->setClass('Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes'); ob_start(); @@ -677,32 +677,32 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() public function testUnusedFunctionsOfAutoDiscoverThrowException() { - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); try { $server->setPersistence("bogus"); $this->fail(); - } catch(Zend_Soap_AutoDiscover_Exception $e) { + } catch(AutoDiscover\Exception $e) { } try { $server->fault(); $this->fail(); - } catch(Zend_Soap_AutoDiscover_Exception $e) { + } catch(AutoDiscover\Exception $e) { } try { $server->loadFunctions("bogus"); $this->fail(); - } catch(Zend_Soap_AutoDiscover_Exception $e) { + } catch(AutoDiscover\Exception $e) { } } public function testGetFunctions() { - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); $server->setClass('Zend_Soap_AutoDiscover_Test'); @@ -720,28 +720,28 @@ public function testUsingRequestUriWithoutParametersAsDefault() { // Apache $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost'); - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $uri = $server->getUri()->getUri(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("http://localhost/my_script.php", $uri); // Apache plus SSL $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on'); - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $uri = $server->getUri()->getUri(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("https://localhost/my_script.php", $uri); // IIS 5 + PHP as FastCGI $_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $uri = $server->getUri()->getUri(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("http://localhost/my_script.php", $uri); // IIS $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $uri = $server->getUri()->getUri(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("http://localhost/my_script.php", $uri); @@ -752,7 +752,7 @@ public function testUsingRequestUriWithoutParametersAsDefault() */ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() { - $server = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); + $server = new AutoDiscover\AutoDiscover('Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex'); $server->setClass('Zend_Soap_AutoDiscoverTestClass2'); ob_start(); @@ -782,7 +782,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() */ public function testDumpOrXmlOfAutoDiscover() { - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); ob_start(); @@ -790,8 +790,8 @@ public function testDumpOrXmlOfAutoDiscover() $wsdlOutput = ob_get_clean(); $this->assertEquals( - $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), - $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) + $this->sanitizeWSDLXmlOutputForOsCompability($wsdlOutput), + $this->sanitizeWSDLXmlOutputForOsCompability($server->toXml()) ); ob_start(); @@ -799,29 +799,29 @@ public function testDumpOrXmlOfAutoDiscover() $wsdlOutput = ob_get_clean(); $this->assertEquals( - $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), - $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) + $this->sanitizeWSDLXmlOutputForOsCompability($wsdlOutput), + $this->sanitizeWSDLXmlOutputForOsCompability($server->toXml()) ); } /** * @group ZF-5330 */ - public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWsdl() + public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWSDL() { - $server = new Zend_Soap_AutoDiscover(); + $server = new AutoDiscover\AutoDiscover(); try { $server->dump(false); $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception); + } catch(\Exception $e) { + $this->assertTrue($e instanceof AutoDiscover\Exception); } try { $server->toXml(); $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_AutoDiscover_Exception); + } catch(\Exception $e) { + $this->assertTrue($e instanceof AutoDiscover\Exception); } } @@ -830,7 +830,7 @@ public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWsdl() */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex() { - $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); + $autodiscover = new AutoDiscover\AutoDiscover('Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex'); $autodiscover->setClass('Zend_Soap_AutoDiscover_MyService'); $wsdl = $autodiscover->toXml(); @@ -844,7 +844,7 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayC */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence() { - $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence'); + $autodiscover = new AutoDiscover\AutoDiscover('Zend_Soap_WSDL_Strategy_ArrayOfTypeSequence'); $autodiscover->setClass('Zend_Soap_AutoDiscover_MyServiceSequence'); $wsdl = $autodiscover->toXml(); @@ -860,7 +860,7 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayS */ public function testAmpersandInUrlIsCorrectlyEncoded() { - $autodiscover = new Zend_Soap_AutoDiscover(); + $autodiscover = new AutoDiscover\AutoDiscover(); $autodiscover->setUri("http://example.com/?a=b&b=c"); $autodiscover->setClass("Zend_Soap_AutoDiscover_Test"); @@ -874,7 +874,7 @@ public function testAmpersandInUrlIsCorrectlyEncoded() */ public function testNoReturnIsOneWayCallInSetClass() { - $autodiscover = new Zend_Soap_AutoDiscover(); + $autodiscover = new AutoDiscover\AutoDiscover(); $autodiscover->setClass('Zend_Soap_AutoDiscover_NoReturnType'); $wsdl = $autodiscover->toXml(); @@ -889,7 +889,7 @@ public function testNoReturnIsOneWayCallInSetClass() */ public function testNoReturnIsOneWayCallInAddFunction() { - $autodiscover = new Zend_Soap_AutoDiscover(); + $autodiscover = new AutoDiscover\AutoDiscover(); $autodiscover->addFunction('Zend_Soap_AutoDiscover_OneWay'); $wsdl = $autodiscover->toXml(); diff --git a/test/ClientTest.php b/test/ClientTest.php index 73f2aeb4..9ba2d3d7 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -20,6 +20,13 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap; +use Zend\Soap\Client; +use Zend\Soap\Server; + if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Zend_Soap_ClientTest::main'); } @@ -40,7 +47,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ -class Zend_Soap_ClientTest extends PHPUnit_Framework_TestCase +class ClientTest extends \PHPUnit_Framework_TestCase { /** * Runs this test suite @@ -49,8 +56,8 @@ class Zend_Soap_ClientTest extends PHPUnit_Framework_TestCase */ public static function main() { - $suite = new PHPUnit_Framework_TestSuite(__CLASS__); - $result = PHPUnit_TextUI_TestRunner::run($suite); + $suite = new \PHPUnit_Framework_TestSuite(__CLASS__); + $result = \PHPUnit_TextUI_TestRunner::run($suite); } public function setUp() @@ -65,13 +72,13 @@ public function testSetOptions() /************************************************************* * ------ Test WSDL mode options ----------------------------- *************************************************************/ - $client = new Zend_Soap_Client(); + $client = new Client\Client(); $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); $ctx = stream_context_create(); - $nonWsdlOptions = array('soap_version' => SOAP_1_1, + $nonWSDLOptions = array('soap_version' => SOAP_1_1, 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', 'TestData2' => 'Zend_Soap_Client_TestData2',), 'encoding' => 'ISO-8859-1', @@ -97,14 +104,14 @@ public function testSetOptions() 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); - $client->setOptions($nonWsdlOptions); - $this->assertTrue($client->getOptions() == $nonWsdlOptions); + $client->setOptions($nonWSDLOptions); + $this->assertTrue($client->getOptions() == $nonWSDLOptions); /************************************************************* * ------ Test non-WSDL mode options ----------------------------- *************************************************************/ - $client1 = new Zend_Soap_Client(); + $client1 = new Client\Client(); $this->assertTrue($client1->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); @@ -135,7 +142,7 @@ public function testSetOptions() public function testGetOptions() { - $client = new Zend_Soap_Client(); + $client = new Client\Client(); $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); @@ -172,7 +179,7 @@ public function testGetOptions() */ public function testGetAndSetUserAgentOption() { - $client = new Zend_Soap_Client(); + $client = new Client\Client(); $this->assertNull($client->getUserAgent()); $client->setUserAgent('agent1'); @@ -202,7 +209,7 @@ public function testGetAndSetUserAgentOption() */ public function testUserAgentAllowsEmptyString() { - $client = new Zend_Soap_Client(); + $client = new Client\Client(); $this->assertNull($client->getUserAgent()); $options = $client->getOptions(); $this->assertArrayNotHasKey('user_agent', $options); @@ -220,10 +227,10 @@ public function testUserAgentAllowsEmptyString() public function testGetFunctions() { - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $this->assertTrue($client->getFunctions() == array('string testFunc1()', 'string testFunc2(string $who)', @@ -249,10 +256,10 @@ public function testGetLastRequest() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); // Perform request $client->testFunc2('World'); @@ -279,10 +286,10 @@ public function testGetLastResponse() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); // Perform request $client->testFunc2('World'); @@ -310,10 +317,10 @@ public function testCallInvoke() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $this->assertEquals($client->testFunc2('World'), 'Hello World!'); } @@ -322,7 +329,7 @@ public function testSetOptionsWithZendConfig() { $ctx = stream_context_create(); - $nonWsdlOptions = array('soap_version' => SOAP_1_1, + $nonWSDLOptions = array('soap_version' => SOAP_1_1, 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', 'TestData2' => 'Zend_Soap_Client_TestData2',), 'encoding' => 'ISO-8859-1', @@ -347,11 +354,11 @@ public function testSetOptionsWithZendConfig() 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5 ); - $config = new Zend_Config($nonWsdlOptions); + $config = new \Zend\Config\Config($nonWSDLOptions); - $client = new Zend_Soap_Client(null, $config); + $client = new Client\Client(null, $config); - $this->assertEquals($nonWsdlOptions, $client->getOptions()); + $this->assertEquals($nonWSDLOptions, $client->getOptions()); } public function testSetInputHeaders() @@ -361,15 +368,15 @@ public function testSetInputHeaders() return; } - $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); $server->setClass('Zend_Soap_Client_TestClass'); - $client = new Zend_Soap_Client_Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); // Add request header - $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader1', 'SOAP header content 1')); + $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader1', 'SOAP header content 1')); // Add permanent request header - $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader2', 'SOAP header content 2'), true); + $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader2', 'SOAP header content 2'), true); // Perform request $client->testFunc2('World'); @@ -395,7 +402,7 @@ public function testSetInputHeaders() // Add request header - $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader3', 'SOAP header content 3')); + $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader3', 'SOAP header content 3')); // Perform request $client->testFunc2('World'); @@ -423,7 +430,7 @@ public function testSetInputHeaders() $client->resetSoapInputHeaders(); // Add request header - $client->addSoapInputHeader(new SoapHeader('http://www.example.com/namespace', 'MyHeader4', 'SOAP header content 4')); + $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader4', 'SOAP header content 4')); // Perform request $client->testFunc2('World'); @@ -460,7 +467,7 @@ public function testSetCookieIsDelegatedToSoapClient() ->method('__setCookie') ->with($fixtureCookieKey, $fixtureCookieValue); - $soap = new Zend_Soap_Client(); + $soap = new Client\Client(); $soap->setSoapClient($clientMock); $soap->setCookie($fixtureCookieKey, $fixtureCookieValue); @@ -470,7 +477,7 @@ public function testSetSoapClient() { $clientMock = $this->getMock('SoapClient', array('__setCookie'), array(null, array('uri' => 'http://www.zend.com', 'location' => 'http://www.zend.com'))); - $soap = new Zend_Soap_Client(); + $soap = new Client\Client(); $soap->setSoapClient($clientMock); $this->assertSame($clientMock, $soap->getSoapClient()); @@ -479,7 +486,7 @@ public function testSetSoapClient() /** Test Class */ -class Zend_Soap_Client_TestClass { +class TestClass { /** * Test Function 1 * @@ -525,7 +532,7 @@ static function testFunc4() } /** Test class 2 */ -class Zend_Soap_Client_TestData1 { +class TestData1 { /** * Property1 * @@ -542,7 +549,7 @@ class Zend_Soap_Client_TestData1 { } /** Test class 2 */ -class Zend_Soap_Client_TestData2 { +class TestData2 { /** * Property1 * @@ -621,5 +628,5 @@ function Zend_Soap_Client_TestFunc6() } if (PHPUnit_MAIN_METHOD == 'Zend_Soap_ClientTest::main') { - Zend_Soap_ClientTest::main(); + \Zend_Soap_ClientTest::main(); } diff --git a/test/ServerTest.php b/test/ServerTest.php index 5e740c46..82333218 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -20,6 +20,11 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap; +use Zend\Soap\Server; /** PHPUnit Test Case */ @@ -39,7 +44,7 @@ * @group Zend_Soap * @group Zend_Soap_Server */ -class Zend_Soap_ServerTest extends PHPUnit_Framework_TestCase +class ServerTest extends \PHPUnit_Framework_TestCase { public function setUp() { @@ -50,7 +55,7 @@ public function setUp() public function testSetOptions() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); @@ -78,22 +83,22 @@ public function testSetOptionsViaSecondConstructorArgument() 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', ); - $server = new Zend_Soap_Server(null, $options); + $server = new Server\Server(null, $options); $this->assertTrue($server->getOptions() == $options); } - public function testSetWsdlViaOptionsArrayIsPossible() + public function testSetWSDLViaOptionsArrayIsPossible() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setOptions(array('wsdl' => 'http://www.example.com/test.wsdl')); - $this->assertEquals('http://www.example.com/test.wsdl', $server->getWsdl()); + $this->assertEquals('http://www.example.com/test.wsdl', $server->getWSDL()); } public function testGetOptions() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); @@ -107,7 +112,7 @@ public function testGetOptions() public function testEncoding() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getEncoding()); $server->setEncoding('ISO-8859-1'); @@ -116,14 +121,14 @@ public function testEncoding() try { $server->setEncoding(array('UTF-8')); $this->fail('Non-string encoding values should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testSoapVersion() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertEquals(SOAP_1_2, $server->getSoapVersion()); $server->setSoapVersion(SOAP_1_1); @@ -131,19 +136,19 @@ public function testSoapVersion() try { $server->setSoapVersion('bogus'); $this->fail('Invalid soap versions should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testValidateUrn() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->validateUrn('bogosity'); $this->fail('URNs without schemes should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } @@ -153,7 +158,7 @@ public function testValidateUrn() public function testSetActor() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); @@ -161,14 +166,14 @@ public function testSetActor() try { $server->setActor('bogus'); $this->fail('Invalid actor should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testGetActor() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); @@ -177,7 +182,7 @@ public function testGetActor() public function testSetUri() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); @@ -185,14 +190,14 @@ public function testSetUri() try { $server->setUri('bogus'); $this->fail('Invalid URI should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testGetUri() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); @@ -201,7 +206,7 @@ public function testGetUri() public function testSetClassmap() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', 'TestData2' => 'Zend_Soap_Server_TestData2'); @@ -212,20 +217,20 @@ public function testSetClassmap() try { $server->setClassmap('bogus'); $this->fail('Classmap which is not an array should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } try { $server->setClassmap(array('soapTypeName', 'bogusClassName')); $this->fail('Invalid class within classmap should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testGetClassmap() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', 'TestData2' => 'Zend_Soap_Server_TestData2'); @@ -235,33 +240,33 @@ public function testGetClassmap() $this->assertTrue($classmap == $server->getClassmap()); } - public function testSetWsdl() + public function testSetWSDL() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); - $this->assertNull($server->getWsdl()); - $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); - $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl()); + $this->assertNull($server->getWSDL()); + $server->setWSDL(dirname(__FILE__).'/_files/wsdl_example.wsdl'); + $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWSDL()); try { - $server->setWsdl(dirname(__FILE__).'/_files/bogus.wsdl'); + $server->setWSDL(dirname(__FILE__).'/_files/bogus.wsdl'); $this->fail('Invalid WSDL URI or PATH should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } - public function testGetWsdl() + public function testGetWSDL() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); - $this->assertNull($server->getWsdl()); - $server->setWsdl(dirname(__FILE__).'/_files/wsdl_example.wsdl'); - $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWsdl()); + $this->assertNull($server->getWSDL()); + $server->setWSDL(dirname(__FILE__).'/_files/wsdl_example.wsdl'); + $this->assertEquals(dirname(__FILE__).'/_files/wsdl_example.wsdl', $server->getWSDL()); } public function testAddFunction() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); // Correct function should pass $server->addFunction('Zend_Soap_Server_TestFunc1'); @@ -280,30 +285,30 @@ public function testAddFunction() public function testAddBogusFunctionAsInteger() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->addFunction(126); $this->fail('Invalid value should fail'); - } catch (Zend_Soap_Server_Exception $e) { + } catch (Server\Exception $e) { // success } } public function testAddBogusFunctionsAsString() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->addFunction('bogus_function'); $this->fail('Invalid function should fail.'); - } catch (Zend_Soap_Server_Exception $e) { + } catch (Server\Exception $e) { // success } } public function testAddBogusFunctionsAsArray() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $functions = array('Zend_Soap_Server_TestFunc5', @@ -311,14 +316,14 @@ public function testAddBogusFunctionsAsArray() 'Zend_Soap_Server_TestFunc6'); $server->addFunction($functions); $this->fail('Invalid function within a set of functions should fail'); - } catch (Zend_Soap_Server_Exception $e) { + } catch (Server\Exception $e) { // success } } public function testAddAllFunctionsSoapConstant() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); // SOAP_FUNCTIONS_ALL as a value should pass $server->addFunction(SOAP_FUNCTIONS_ALL); @@ -328,62 +333,62 @@ public function testAddAllFunctionsSoapConstant() public function testSetClass() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); // Correct class name should pass try { $server->setClass('Zend_Soap_Server_TestClass'); - } catch(Exception $e) { + } catch(\Exception $e) { $this->fail("Setting a correct class name should not fail setClass()"); } } public function testSetClassTwiceThrowsException() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); // Correct class name should pass try { $server->setClass('Zend_Soap_Server_TestClass'); $server->setClass('Zend_Soap_Server_TestClass'); $this->fail(); - } catch(Zend_Soap_Server_Exception $e) { + } catch(Server\Exception $e) { $this->assertEquals('A class has already been registered with this soap server instance', $e->getMessage()); } } public function testSetClassWithArguments() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); // Correct class name should pass try { $server->setClass('Zend_Soap_Server_TestClass', 1, 2, 3, 4); - } catch(Exception $e) { + } catch(\Exception $e) { $this->fail("Setting a correct class name should not fail setClass()"); } } public function testSetBogusClassWithIntegerName() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->setClass(465); $this->fail('Non-string value should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testSetBogusClassWithUnknownClassName() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->setClass('Zend_Soap_Server_Test_BogusClass'); $this->fail('Invalid class should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } @@ -393,12 +398,12 @@ public function testSetBogusClassWithUnknownClassName() */ public function testSetObject() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->setObject(465); $this->fail('Non-object value should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } @@ -406,24 +411,24 @@ public function testSetObject() $int = 1; $server->setObject($int); $this->fail('Invalid argument should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } // Correct class name should pass - $server->setObject(new Zend_Soap_Server_TestClass()); + $server->setObject(new \Zend_Soap_Server_TestClass()); try { - $server->setObject(new Zend_Soap_Server_TestClass()); + $server->setObject(new \Zend_Soap_Server_TestClass()); $this->fail('setClass() should pass only once'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } } public function testGetFunctions() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->addFunction('Zend_Soap_Server_TestFunc1'); @@ -450,7 +455,7 @@ public function testGetFunctions() public function testGetFunctionsWithClassAttached() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setClass('Zend_Soap_Server_TestClass'); $this->assertEquals( @@ -461,8 +466,8 @@ public function testGetFunctionsWithClassAttached() public function testGetFunctionsWithObjectAttached() { - $server = new Zend_Soap_Server(); - $server->setObject(new Zend_Soap_Server_TestClass()); + $server = new Server\Server(); + $server->setObject(new \Zend_Soap_Server_TestClass()); $this->assertEquals( array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), @@ -472,7 +477,7 @@ public function testGetFunctionsWithObjectAttached() public function testSetPersistence() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getPersistence()); $server->setPersistence(SOAP_PERSISTENCE_SESSION); @@ -480,7 +485,7 @@ public function testSetPersistence() try { $server->setSoapVersion('bogus'); $this->fail('Invalid soap versions should fail'); - } catch (Exception $e) { + } catch (\Exception $e) { // success } @@ -490,19 +495,19 @@ public function testSetPersistence() public function testSetUnknownPersistenceStateThrowsException() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->setPersistence('bogus'); $this->fail(); - } catch(Zend_Soap_Server_Exception $e) { + } catch(Server\Exception $e) { } } public function testGetPersistence() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getPersistence()); $server->setPersistence(SOAP_PERSISTENCE_SESSION); @@ -516,7 +521,7 @@ public function testGetLastRequest() return; } - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -544,7 +549,7 @@ public function testGetLastRequest() public function testSetReturnResponse() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertFalse($server->getReturnResponse()); @@ -557,7 +562,7 @@ public function testSetReturnResponse() public function testGetReturnResponse() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertFalse($server->getReturnResponse()); @@ -572,7 +577,7 @@ public function testGetLastResponse() return; } - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -620,12 +625,12 @@ public function testHandle() return; } - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setClass('Zend_Soap_Server_TestClass'); - $localClient = new Zend_Soap_Server_TestLocalSoapClient($server, + $localClient = new \Zend_Soap_Server_TestLocalSoapClient($server, null, array('location'=>'test://', 'uri'=>'http://framework.zend.com')); @@ -664,7 +669,7 @@ public function testHandle() . '' . '' . "\n"; - $server1 = new Zend_Soap_Server(); + $server1 = new Server\Server(); $server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server1->setClass('Zend_Soap_Server_TestClass'); @@ -678,7 +683,7 @@ public function testHandle() */ public function testRegisterFaultException() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->registerFaultException("Zend_Soap_Server_Exception"); $server->registerFaultException(array("OutOfBoundsException", "BogusException")); @@ -695,7 +700,7 @@ public function testRegisterFaultException() */ public function testDeregisterFaultException() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->registerFaultException(array("OutOfBoundsException", "BogusException")); $ret = $server->deregisterFaultException("BogusException"); @@ -714,7 +719,7 @@ public function testDeregisterFaultException() */ public function testGetFaultExceptions() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertEquals(array(), $server->getFaultExceptions()); $server->registerFaultException("Exception"); @@ -723,37 +728,37 @@ public function testGetFaultExceptions() public function testFaultWithTextMessage() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $fault = $server->fault("Faultmessage!"); - $this->assertTrue($fault instanceof SOAPFault); + $this->assertTrue($fault instanceof \SOAPFault); $this->assertContains("Faultmessage!", $fault->getMessage()); } public function testFaultWithUnregisteredException() { - $server = new Zend_Soap_Server(); - $fault = $server->fault(new Exception("MyException")); + $server = new Server\Server(); + $fault = $server->fault(new \Exception("MyException")); - $this->assertTrue($fault instanceof SOAPFault); + $this->assertTrue($fault instanceof \SOAPFault); $this->assertContains("Unknown error", $fault->getMessage()); $this->assertNotContains("MyException", $fault->getMessage()); } public function testFaultWithRegisteredException() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->registerFaultException("Exception"); - $fault = $server->fault(new Exception("MyException")); + $fault = $server->fault(new \Exception("MyException")); - $this->assertTrue($fault instanceof SOAPFault); + $this->assertTrue($fault instanceof \SOAPFault); $this->assertNotContains("Unknown error", $fault->getMessage()); $this->assertContains("MyException", $fault->getMessage()); } public function testFautlWithBogusInput() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $fault = $server->fault(array("Here", "There", "Bogus")); $this->assertContains("Unknown error", $fault->getMessage()); @@ -764,10 +769,10 @@ public function testFautlWithBogusInput() */ public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $fault = $server->fault("Faultmessage!", 5000); - $this->assertTrue($fault instanceof SOAPFault); + $this->assertTrue($fault instanceof \SOAPFault); } /** @@ -775,7 +780,7 @@ public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault() */ public function testHandlePhpErrors() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); // Remove the following line when you implement this test. $this->markTestIncomplete( @@ -785,12 +790,12 @@ public function testHandlePhpErrors() public function testLoadFunctionsIsNotImplemented() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); try { $server->loadFunctions("bogus"); $this->fail(); - } catch(Zend_Soap_Server_Exception $e) { + } catch(Server\Exception $e) { } } @@ -802,7 +807,7 @@ public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHan return; } - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -841,9 +846,9 @@ public function testServerAcceptsZendConfigObject() 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' ); - $config = new Zend_Config($options); + $config = new \Zend\Config\Config($options); - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $server->setOptions($config); $this->assertEquals($options, $server->getOptions()); } @@ -853,7 +858,7 @@ public function testServerAcceptsZendConfigObject() */ public function testSetAndGetFeatures() { - $server = new Zend_Soap_Server(); + $server = new Server\Server(); $this->assertNull($server->getSoapFeatures()); $server->setSoapFeatures(100); $this->assertEquals(100, $server->getSoapFeatures()); @@ -865,12 +870,12 @@ public function testSetAndGetFeatures() /** * @group ZF-5300 */ - public function testSetAndGetWsdlCache() + public function testSetAndGetWSDLCache() { - $server = new Zend_Soap_Server(); - $this->assertNull($server->getWsdlCache()); - $server->setWsdlCache(100); - $this->assertEquals(100, $server->getWsdlCache()); + $server = new Server\Server(); + $this->assertNull($server->getWSDLCache()); + $server->setWSDLCache(100); + $this->assertEquals(100, $server->getWSDLCache()); $options = $server->getOptions(); $this->assertTrue(isset($options['cache_wsdl'])); $this->assertEquals(100, $options['cache_wsdl']); @@ -881,7 +886,7 @@ public function testSetAndGetWsdlCache() if (extension_loaded('soap')) { /** Local SOAP client */ -class Zend_Soap_Server_TestLocalSoapClient extends SoapClient +class TestLocalSoapClient extends \SoapClient { /** * Server object @@ -897,7 +902,7 @@ class Zend_Soap_Server_TestLocalSoapClient extends SoapClient * @param string $wsdl * @param array $options */ - function __construct(Zend_Soap_Server $server, $wsdl, $options) + function __construct(Server\Server $server, $wsdl, $options) { $this->server = $server; parent::__construct($wsdl, $options); @@ -917,7 +922,7 @@ function __doRequest($request, $location, $action, $version, $one_way = 0) /** Test Class */ -class Zend_Soap_Server_TestClass { +class TestClass { /** * Test Function 1 * @@ -974,7 +979,7 @@ function testFunc5() /** Test class 2 */ -class Zend_Soap_Server_TestData1 { +class TestData1 { /** * Property1 * @@ -991,7 +996,7 @@ class Zend_Soap_Server_TestData1 { } /** Test class 2 */ -class Zend_Soap_Server_TestData2 { +class TestData2 { /** * Property1 * diff --git a/test/WSDL/ArrayOfTypeComplexStrategyTest.php b/test/WSDL/ArrayOfTypeComplexStrategyTest.php new file mode 100644 index 00000000..167b925a --- /dev/null +++ b/test/WSDL/ArrayOfTypeComplexStrategyTest.php @@ -0,0 +1,233 @@ +strategy = new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex(); + $this->wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); + } + + public function testNestingObjectsDeepMakesNoSenseThrowingException() + { + try { + $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexTest[][]'); + $this->fail(); + } catch(WSDL\Exception $e) { + + } + } + + public function testAddComplexTypeOfNonExistingClassThrowsException() + { + try { + $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\UnknownClass[]'); + } catch(WSDL\Exception $e) { + + } + } + + /** + * @group ZF-5046 + */ + public function testArrayOfSimpleObject() + { + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexTest[]'); + $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexTest", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + } + + public function testThatOverridingStrategyIsReset() + { + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexTest[]'); + $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexTest", $return); + #$this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplexStrategy); + + $wsdl = $this->wsdl->toXML(); + } + + /** + * @group ZF-5046 + */ + public function testArrayOfComplexObjects() + { + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectStructure[]'); + $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexObjectStructure", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + } + + public function testArrayOfObjectWithObject() + { + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); + $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure", $return); + + $wsdl = $this->wsdl->toXML(); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + + $this->assertContains( + '', + $wsdl + ); + } + + /** + * @group ZF-4937 + */ + public function testAddingTypesMultipleTimesIsSavedOnlyOnce() + { + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); + + $wsdl = $this->wsdl->toXML(); + + $this->assertEquals(1, + substr_count($wsdl, 'wsdl:arrayType="tns:\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]"') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + } + + /** + * @group ZF-4937 + */ + public function testAddingSingularThenArrayTypeIsRecognizedCorretly() + { + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); + + $wsdl = $this->wsdl->toXML(); + + $this->assertEquals(1, + substr_count($wsdl, 'wsdl:arrayType="tns:\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]"') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + $this->assertEquals(1, + substr_count($wsdl, '') + ); + } + + /** + * @group ZF-5149 + */ + public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowingException() + { + try { + $return = $this->wsdl->addComplexType("\ZendTest\Soap\WSDL\ComplexTypeA"); + $wsdl = $this->wsdl->toXml(); + } catch(\Exception $e) { + $this->fail("Adding object with nested structure should not throw exception."); + } + } + + /** + * @group ZF-5149 + */ + public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllTypesRecursivly() + { + $return = $this->wsdl->addComplexType("\ZendTest\Soap\WSDL\ComplexTypeA"); + $wsdl = $this->wsdl->toXml(); + + $this->assertEquals(1, + substr_count($wsdl, ''), + 'No definition of complex type A found.' + ); + $this->assertEquals(1, + substr_count($wsdl, ''), + 'No definition of complex type B array found.' + ); + $this->assertEquals(1, + substr_count($wsdl, 'wsdl:arrayType="tns:\ZendTest\Soap\WSDL\ComplexTypeB[]"'), + 'No usage of Complex Type B array found.' + ); + } + + /** + * @group ZF-5754 + */ + public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() + { + try { + $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Exception); + $this->assertEquals('Infinite recursion, cannot nest \'\ZendTest\Soap\_files\Recursion\' into itself.', $e->getMessage()); + } + } +} diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php similarity index 73% rename from test/Wsdl/ArrayOfTypeSequenceStrategyTest.php rename to test/WSDL/ArrayOfTypeSequenceStrategyTest.php index 23eceed2..22bec921 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php @@ -19,6 +19,11 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\WSDL; + /** * @category Zend * @package Zend_Soap @@ -26,17 +31,17 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_Wsdl + * @group Zend_Soap_WSDL */ -class Zend_Soap_Wsdl_ArrayOfTypeSequenceStrategyTest extends PHPUnit_Framework_TestCase +class ArrayOfTypeSequenceStrategyTest extends \PHPUnit_Framework_TestCase { private $wsdl; private $strategy; public function setUp() { - $this->strategy = new Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence(); - $this->wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $this->strategy); + $this->strategy = new \Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence(); + $this->wsdl = new \Zend\Soap\WSDL\WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); } public function testFunctionReturningSimpleArrayOfInts() @@ -66,7 +71,7 @@ public function testFunctionReturningSimpleArrayOfString() public function testFunctionReturningNestedArrayOfString() { $return = $this->wsdl->addComplexType('string[][]'); - $this->assertEquals("tns:ArrayOfArrayOfString", $return); + $this->assertEquals('tns:ArrayOfArrayOfString', $return); $wsdl = $this->wsdl->toXML(); @@ -85,7 +90,7 @@ public function testFunctionReturningNestedArrayOfString() public function testFunctionReturningMultipleNestedArrayOfType() { $return = $this->wsdl->addComplexType('string[][][]'); - $this->assertEquals("tns:ArrayOfArrayOfArrayOfString", $return); + $this->assertEquals('tns:ArrayOfArrayOfArrayOfString', $return); $wsdl = $this->wsdl->toXML(); @@ -109,14 +114,14 @@ public function testFunctionReturningMultipleNestedArrayOfType() public function testAddComplexTypeObject() { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\SequenceTest'); - $this->assertEquals("tns:Zend_Soap_Wsdl_SequenceTest", $return); + $this->assertEquals('tns:\ZendTest\Soap\WSDL\SequenceTest', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); } @@ -124,32 +129,32 @@ public function testAddComplexTypeObject() public function testAddComplexTypeArrayOfObject() { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_SequenceTest[]'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\SequenceTest[]'); - $this->assertEquals("tns:ArrayOfZend_soap_wsdl_sequencetest", $return); + $this->assertEquals('tns:ArrayOf\ZendTest\Soap\WSDL\Sequencetest', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); $this->assertContains( - '', + '', $wsdl ); } public function testAddComplexTypeOfNonExistingClassThrowsException() { - $this->setExpectedException("Zend_Soap_Wsdl_Exception"); + $this->setExpectedException('\Zend\Soap\WSDL\Exception'); - $this->wsdl->addComplexType('Some_Soap_Wsdl_UnknownClass[]'); + $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\UnknownClass[]'); } } -class Zend_Soap_Wsdl_SequenceTest +class SequenceTest { /** * @var int diff --git a/test/WSDL/CompositeStrategyTest.php b/test/WSDL/CompositeStrategyTest.php new file mode 100644 index 00000000..d34cf6fe --- /dev/null +++ b/test/WSDL/CompositeStrategyTest.php @@ -0,0 +1,147 @@ +connectTypeToStrategy('Book', '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + + $bookStrategy = $strategy->getStrategyOfType('Book'); + $cookieStrategy = $strategy->getStrategyOfType('Cookie'); + + $this->assertTrue( $bookStrategy instanceof Strategy\ArrayOfTypeComplex ); + $this->assertTrue( $cookieStrategy instanceof Strategy\ArrayOfTypeSequence ); + } + + public function testConstructorTypeMapSyntax() + { + $typeMap = array('Book' => '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + + $strategy = new Strategy\Composite($typeMap, '\Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence'); + + $bookStrategy = $strategy->getStrategyOfType('Book'); + $cookieStrategy = $strategy->getStrategyOfType('Cookie'); + + $this->assertTrue( $bookStrategy instanceof Strategy\ArrayOfTypeComplex ); + $this->assertTrue( $cookieStrategy instanceof Strategy\ArrayOfTypeSequence ); + } + + public function testCompositeThrowsExceptionOnInvalidType() + { + $strategy = new Strategy\Composite(); + try { + $strategy->connectTypeToStrategy(array(), 'strategy'); + $this->fail(); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Exception); + } + } + + public function testCompositeThrowsExceptionOnInvalidStrategy() + { + $strategy = new Strategy\Composite(array(), 'invalid'); + $strategy->connectTypeToStrategy('Book', 'strategy'); + + try { + $book = $strategy->getStrategyOfType('Book'); + $this->fail(); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Exception); + } + + try { + $book = $strategy->getStrategyOfType('Anything'); + $this->fail(); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Exception); + } + } + + public function testCompositeDelegatesAddingComplexTypesToSubStrategies() + { + $strategy = new Strategy\Composite(array(), '\Zend\Soap\WSDL\Strategy\AnyType'); + $strategy->connectTypeToStrategy('\ZendTest\Soap\WSDL\Book', '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $strategy->connectTypeToStrategy('\ZendTest\Soap\WSDL\Cookie', '\Zend\Soap\WSDL\Strategy\DefaultComplexType'); + + $wsdl = new WSDL\WSDL('SomeService', 'http://example.com'); + $strategy->setContext($wsdl); + + $this->assertEquals('tns:\ZendTest\Soap\WSDL\Book', $strategy->addComplexType('\ZendTest\Soap\WSDL\Book')); + $this->assertEquals('tns:\ZendTest\Soap\WSDL\Cookie', $strategy->addComplexType('\ZendTest\Soap\WSDL\Cookie')); + $this->assertEquals('xsd:anyType', $strategy->addComplexType('\ZendTest\Soap\WSDL\Anything')); + } + + public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrowsException() + { + $strategy = new Strategy\Composite(); + try { + $strategy->addComplexType('Test'); + $this->fail(); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Exception); + } + } +} + +class Book +{ + /** + * @var int + */ + public $somevar; +} +class Cookie +{ + /** + * @var int + */ + public $othervar; +} +class Anything +{ +} diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/WSDL/DefaultComplexTypeTest.php similarity index 67% rename from test/Wsdl/DefaultComplexTypeTest.php rename to test/WSDL/DefaultComplexTypeTest.php index e6fa345e..551d2d1d 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/WSDL/DefaultComplexTypeTest.php @@ -20,7 +20,10 @@ * @version $Id$ */ - +/** + * @namespace + */ +namespace ZendTest\Soap\WSDL; /** * @category Zend @@ -29,24 +32,24 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_Wsdl + * @group Zend_Soap_WSDL */ -class Zend_Soap_Wsdl_DefaultComplexTypeTest extends PHPUnit_Framework_TestCase +class DefaultComplexTypeTest extends \PHPUnit_Framework_TestCase { /** - * @var Zend_Soap_Wsdl + * @var Zend_Soap_WSDL */ private $wsdl; /** - * @var Zend_Soap_Wsdl_Strategy_DefaultComplexType + * @var Zend_Soap_WSDL_Strategy_DefaultComplexType */ private $strategy; public function setUp() { - $this->strategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType(); - $this->wsdl = new Zend_Soap_Wsdl("TestService", "http://framework.zend.com/soap/unittests"); + $this->strategy = new \Zend\Soap\WSDL\Strategy\DefaultComplexType(); + $this->wsdl = new \Zend\Soap\WSDL\WSDL("TestService", "http://framework.zend.com/soap/unittests"); $this->wsdl->setComplexTypeStrategy($this->strategy); $this->strategy->setContext($this->wsdl); } @@ -56,15 +59,15 @@ public function setUp() */ public function testOnlyPublicPropertiesAreDiscoveredByStrategy() { - $this->strategy->addComplexType("Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected"); + $this->strategy->addComplexType('\ZendTest\Soap\WSDL\DefaultComplexTypeTest\PublicPrivateProtected'); $xml = $this->wsdl->toXML(); - $this->assertNotContains( Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected::PROTECTED_VAR_NAME, $xml); - $this->assertNotContains( Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected::PRIVATE_VAR_NAME, $xml); + $this->assertNotContains( PublicPrivateProtected::PROTECTED_VAR_NAME, $xml); + $this->assertNotContains( PublicPrivateProtected::PRIVATE_VAR_NAME, $xml); } } -class Zend_Soap_Wsdl_DefaultComplexTypeTest_PublicPrivateProtected +class PublicPrivateProtected { const PROTECTED_VAR_NAME = 'bar'; const PRIVATE_VAR_NAME = 'baz'; diff --git a/test/Wsdl/ElementTest.php b/test/WSDL/ElementTest.php similarity index 52% rename from test/Wsdl/ElementTest.php rename to test/WSDL/ElementTest.php index 99067b85..dc82fa35 100644 --- a/test/Wsdl/ElementTest.php +++ b/test/WSDL/ElementTest.php @@ -20,6 +20,12 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\WSDL; +use Zend\Soap\WSDL; + /** * @category Zend; * @package Zend_Soap @@ -27,15 +33,16 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_Wsdl + * @group Zend_Soap_WSDL * @group disable */ -class Zend_Soap_Wsdl_ElementTest extends PHPUnit_Framework_TestCase +class ElementTest extends \PHPUnit_Framework_TestCase { +/* public function testBindingElementApi() { - $operations = new Zend_Soap_Wsdl_Element_Collection("test"); - $binding = new Zend_Soap_Wsdl_Element_Binding("name1", "port1", $operations, "test"); + $operations = new WSDL\Element\Collection("test"); + $binding = new WSDL\Element\Binding("name1", "port1", $operations, "test"); $this->assertEquals("name1", $binding->getName()); $this->assertEquals("port1", $binding->portName); @@ -43,71 +50,71 @@ public function testBindingElementApi() $this->assertEquals("test", $binding->getDocumentation()); try { - $binding = new Zend_Soap_Wsdl_Element_Binding(array(), "portName", $operations, "test"); + $binding = new WSDL\Element\Binding(array(), "portName", $operations, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testTypeElementApi() { - $types = new Zend_Soap_Wsdl_Element_Collection("test"); - $type = new Zend_Soap_Wsdl_Element_Type("name1", $types, "test"); + $types = new WSDL\Element\Collection("test"); + $type = new WSDL\Element\Type("name1", $types, "test"); $this->assertEquals("name1", $type->getName()); $this->assertEquals($types, $type->types); $this->assertEquals("test", $type->getDocumentation()); try { - $type = new Zend_Soap_Wsdl_Element_Type(array(), $types, "test"); + $type = new WSDL\Element\Type(array(), $types, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testMessageElementApi() { - $parts = new Zend_Soap_Wsdl_Element_Collection("test"); - $message = new Zend_Soap_Wsdl_Element_Message("name1", $parts, "test"); + $parts = new WSDL\Element\Collection("test"); + $message = new WSDL\Element\Message("name1", $parts, "test"); $this->assertEquals("name1", $message->getName()); $this->assertEquals($parts, $message->parts); $this->assertEquals("test", $message->getDocumentation()); try { - $message = new Zend_Soap_Wsdl_Element_Message(array(), $parts, "test"); + $message = new WSDL\Element\Message(array(), $parts, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testPortElementApi() { - $operations = new Zend_Soap_Wsdl_Element_Collection("test"); - $port = new Zend_Soap_Wsdl_Element_Port("name1", $operations, "test"); + $operations = new WSDL\Element\Collection("test"); + $port = new WSDL\Element\Port("name1", $operations, "test"); $this->assertEquals("name1", $port->getName()); $this->assertEquals($operations, $port->operations); $this->assertEquals("test", $port->getDocumentation()); try { - $port = new Zend_Soap_Wsdl_Element_Port(array(), $operations, "test"); + $port = new WSDL\Element\Port(array(), $operations, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testOperationElementApi() { - $collection = new Zend_Soap_Wsdl_Element_Collection("test"); - $input = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); - $output = new Zend_Soap_Wsdl_Element_Message("name", $collection, "test"); + $collection = new WSDL\Element\Collection("test"); + $input = new WSDL\Element\Message("name", $collection, "test"); + $output = new WSDL\Element\Message("name", $collection, "test"); - $operation = new Zend_Soap_Wsdl_Element_Operation("name1", $input, $output, "test"); + $operation = new WSDL\Element\Operation("name1", $input, $output, "test"); $this->assertEquals("name1", $operation->getName()); $this->assertEquals($input, $operation->inputMessage); @@ -115,20 +122,20 @@ public function testOperationElementApi() $this->assertEquals("test", $operation->getDocumentation()); try { - $operation = new Zend_Soap_Wsdl_Element_Operation(array(), $input, $output, "test"); + $operation = new WSDL\Element\Operation(array(), $input, $output, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testServiceElementApi() { - $collection = new Zend_Soap_Wsdl_Element_Collection("test"); - $port = new Zend_Soap_Wsdl_Element_Port("name", $collection, "test"); - $binding = new Zend_Soap_Wsdl_Element_Binding("name", "port", $collection, "test"); + $collection = new WSDL\Element\Collection("test"); + $port = new WSDL\Element\Port("name", $collection, "test"); + $binding = new WSDL\Element\Binding("name", "port", $collection, "test"); - $service = new Zend_Soap_Wsdl_Element_Service("service", "address", $port, $binding, "test"); + $service = new WSDL\Element\Service("service", "address", $port, $binding, "test"); $this->assertEquals("service", $service->getName()); $this->assertEquals("address", $service->soapAddress); @@ -137,70 +144,70 @@ public function testServiceElementApi() $this->assertEquals("test", $service->getDocumentation()); try { - $service = new Zend_Soap_Wsdl_Element_Service(array(), "address", $port, $binding, "test"); + $service = new WSDL\Element\Service(array(), "address", $port, $binding, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } try { - $service = new Zend_Soap_Wsdl_Element_Service("name", array(), $port, $binding, "test"); + $service = new WSDL\Element\Service("name", array(), $port, $binding, "test"); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testCollectionElementApiConstruct() { - $collection = new Zend_Soap_Wsdl_Element_Collection("Operation"); + $collection = new WSDL\Element\Collection("Operation"); - $this->assertTrue($collection instanceof Countable); - $this->assertTrue($collection instanceof Iterator); + $this->assertTrue($collection instanceof \Countable); + $this->assertTrue($collection instanceof \Iterator); try { - $type = new Zend_Soap_Wsdl_Element_Type("type", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); + $type = new WSDL\Element\Type("type", new WSDL\Element\Collection("Type"), "test"); $collection->addElement($type); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } try { - $collection = new Zend_Soap_Wsdl_Element_Collection(false); + $collection = new WSDL\Element\Collection(false); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } public function testCollectionElementApiType() { - $collection = new Zend_Soap_Wsdl_Element_Collection("Operation"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Operation", $collection->getType()); + $collection = new WSDL\Element\Collection("Operation"); + $this->assertEquals("\Zend\Soap\WSDL\Element\Operation", $collection->getType()); - $collection = new Zend_Soap_Wsdl_Element_Collection("Type"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Type", $collection->getType()); + $collection = new WSDL\Element\Collection("Type"); + $this->assertEquals("\Zend\Soap\WSDL\Element\Type", $collection->getType()); - $collection = new Zend_Soap_Wsdl_Element_Collection("Binding"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Binding", $collection->getType()); + $collection = new WSDL\Element\Collection("Binding"); + $this->assertEquals("\Zend\Soap\WSDL\Element\Binding", $collection->getType()); - $collection = new Zend_Soap_Wsdl_Element_Collection("Service"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Service", $collection->getType()); + $collection = new WSDL\Element\Collection("Service"); + $this->assertEquals("\Zend\Soap\WSDL\Element\Service", $collection->getType()); - $collection = new Zend_Soap_Wsdl_Element_Collection("Port"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Port", $collection->getType()); + $collection = new WSDL\Element\Collection("Port"); + $this->assertEquals("\Zend\Soap\WSDL\Element\Port", $collection->getType()); - $collection = new Zend_Soap_Wsdl_Element_Collection("Message"); - $this->assertEquals("Zend_Soap_Wsdl_Element_Message", $collection->getType()); + $collection = new WSDL\Element\Collection("Message"); + $this->assertEquals("\Zend\Soap\WSDL\Element\Message", $collection->getType()); } public function testCollectionElementApiElementAccess() { - $collection = new Zend_Soap_Wsdl_Element_Collection("Message"); - $message1 = new Zend_Soap_Wsdl_Element_Message("message1", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); - $message2 = new Zend_Soap_Wsdl_Element_Message("message2", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); - $messageDuplicate = new Zend_Soap_Wsdl_Element_Message("message2", new Zend_Soap_Wsdl_Element_Collection("Type"), "test"); + $collection = new WSDL\Element\Collection("Message"); + $message1 = new WSDL\Element\Message("message1", new WSDL\Element\Collection("Type"), "test"); + $message2 = new WSDL\Element\Message("message2", new WSDL\Element\Collection("Type"), "test"); + $messageDuplicate = new WSDL\Element\Message("message2", new WSDL\Element\Collection("Type"), "test"); $collection->addElement($message1); $this->assertEquals(array("message1"), $collection->getElementNames()); @@ -216,7 +223,7 @@ public function testCollectionElementApiElementAccess() // Adding duplicate message leads to exception $collection->addElement($messageDuplicate); $this->fail("Adding a duplicate named element to a collection should throw an exception."); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); $this->assertEquals($message2, $collection->getElement("message2")); $this->assertEquals(2, count($collection)); @@ -226,13 +233,14 @@ public function testCollectionElementApiElementAccess() // Accessing unkown message leads to exception $collection->getElement("messageUnknown"); $this->fail("Accessing unknown element should throw an exception."); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { $this->assertEquals(2, count($collection)); } foreach($collection AS $name => $message) { - $this->assertTrue($message instanceof Zend_Soap_Wsdl_Element_Message); + $this->assertTrue($message instanceof WSDL\Element\Message); $this->assertTrue( in_array($name, $collection->getElementNames()) ); } } +*/ } diff --git a/test/Wsdl/ParserTest.php b/test/WSDL/ParserTest.php similarity index 59% rename from test/Wsdl/ParserTest.php rename to test/WSDL/ParserTest.php index ef73e164..a566a7b7 100644 --- a/test/Wsdl/ParserTest.php +++ b/test/WSDL/ParserTest.php @@ -20,6 +20,11 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\WSDL; +use Zend\Soap\WSDL; /** * @category Zend @@ -28,64 +33,65 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_Wsdl + * @group Zend_Soap_WSDL * @group disable */ -class Zend_Soap_Wsdl_ParserTest extends PHPUnit_Framework_TestCase +class ParserTest extends \PHPUnit_Framework_TestCase { - protected function getWsdlExampleDom() + protected function getWSDLExampleDom() { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl")); return $dom; } +/* public function testFactoryWithDomDocument() { - $dom = $this->getWsdlExampleDom(); - $parser = Zend_Soap_Wsdl_Parser::factory($dom); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + $dom = $this->getWSDLExampleDom(); + $parser = WSDL\Parser::factory($dom); + $this->assertTrue($parser instanceof WSDL\Parser); } public function testFactoryWithString() { $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); - $parser = Zend_Soap_Wsdl_Parser::factory($xmlString); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + $parser = WSDL\Parser::factory($xmlString); + $this->assertTrue($parser instanceof WSDL\Parser); } public function testFactoryWithSimpleXml() { $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); $simpleXml = simplexml_load_string($xmlString); - $parser = Zend_Soap_Wsdl_Parser::factory($simpleXml); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + $parser = WSDL\Parser::factory($simpleXml); + $this->assertTrue($parser instanceof WSDL\Parser); } - public function testFactoryWithZendSoapWsdl() + public function testFactoryWithZendSoapWSDL() { - $wsdl = new Zend_Soap_Wsdl("name", "http://example.com"); - $parser = Zend_Soap_Wsdl_Parser::factory($wsdl); - $this->assertTrue($parser instanceof Zend_Soap_Wsdl_Parser); + $wsdl = new WSDL\WSDL("name", "http://example.com"); + $parser = WSDL\Parser::factory($wsdl); + $this->assertTrue($parser instanceof WSDL\Parser); } public function testFactoryWithInvalidParser() { - $wsdl = new Zend_Soap_Wsdl("name", "http://example.com"); + $wsdl = new WSDL\WSDL("name", "http://example.com"); try { - $parser = Zend_Soap_Wsdl_Parser::factory($wsdl, "stdClass"); + $parser = WSDL\Parser::factory($wsdl, "stdClass"); $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Parser_Exception); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Parser\Exception); } } public function testFactoryWithInvalidData() { try { - $parser = Zend_Soap_Wsdl_Parser::factory(null); + $parser = WSDL\Parser::factory(null); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } @@ -93,56 +99,56 @@ public function testFactoryWithInvalidData() public function testParserApiInterface() { // Constructor expects DOMDocument instance - $dom = $this->getWsdlExampleDom(); - $parser = new Zend_Soap_Wsdl_Parser($dom); + $dom = $this->getWSDLExampleDom(); + $parser = new WSDL\Parser($dom); - // SetWsdl is a fluent function - $this->assertTrue( ($parser->setDomDocumentContainingWsdl($dom)) instanceof Zend_Soap_Wsdl_Parser ); + // SetWSDL is a fluent function + $this->assertTrue( ($parser->setDomDocumentContainingWSDL($dom)) instanceof WSDL\Parser ); // Parse returns Result $result = $parser->parse(); - $this->assertTrue($result instanceof Zend_Soap_Wsdl_Parser_Result); + $this->assertTrue($result instanceof WSDL\Parser\Result); } public function testParserResultApiInterface() { - $result = new Zend_Soap_Wsdl_Parser_Result( + $result = new WSDL\Parser\Result( "name", - Zend_Soap_Wsdl_Parser::WSDL_11, - new Zend_Soap_Wsdl_Element_Collection("Operation"), - new Zend_Soap_Wsdl_Element_Collection("Port"), - new Zend_Soap_Wsdl_Element_Collection("Binding"), - new Zend_Soap_Wsdl_Element_Collection("Service"), - new Zend_Soap_Wsdl_Element_Collection("Type"), + WSDL\Parser::WSDL_11, + new WSDL\Element_Collection("Operation"), + new WSDL\Element_Collection("Port"), + new WSDL\Element_Collection("Binding"), + new WSDL\Element_Collection("Service"), + new WSDL\Element_Collection("Type"), array("docs") ); $this->assertEquals("name", $result->getName()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Operation", $result->operations->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Port", $result->ports->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Binding", $result->bindings->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Service", $result->services->getType()); - $this->assertEquals("Zend_Soap_Wsdl_Element_Type", $result->types->getType()); + $this->assertEquals("Zend_Soap_WSDL_Element_Operation", $result->operations->getType()); + $this->assertEquals("Zend_Soap_WSDL_Element_Port", $result->ports->getType()); + $this->assertEquals("Zend_Soap_WSDL_Element_Binding", $result->bindings->getType()); + $this->assertEquals("Zend_Soap_WSDL_Element_Service", $result->services->getType()); + $this->assertEquals("Zend_Soap_WSDL_Element_Type", $result->types->getType()); $this->assertEquals(array("docs"), $result->documentation); try { $key = $result->invalidKeyThrowsException; $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Parser_Exception); + } catch(\Exception $e) { + $this->assertTrue($e instanceof WSDL\Parser\Exception); } } - public function testParseExampleWsdlAndCountResultElements() + public function testParseExampleWSDLAndCountResultElements() { // Constructor expects DOMDocument instance - $dom = $this->getWsdlExampleDom(); - $parser = new Zend_Soap_Wsdl_Parser($dom); + $dom = $this->getWSDLExampleDom(); + $parser = new WSDL\Parser($dom); $result = $parser->parse(); $this->assertEquals("Zend_Soap_Server_TestClass", $result->getName()); - $this->assertEquals(Zend_Soap_Wsdl_Parser::WSDL_11, $result->getVersion()); + $this->assertEquals(WSDL\Parser::WSDL_11, $result->getVersion()); $this->assertEquals(4, count($result->operations), "Number of operations does not match."); $this->assertEquals(1, count($result->bindings), "Number of bindings does not match."); $this->assertEquals(1, count($result->ports), "Number of ports does not match."); @@ -152,11 +158,11 @@ public function testParseExampleWsdlAndCountResultElements() $this->assertEquals(4, count($result->ports->current()->operations), "Number of operations in the ports collection does not match."); } - public function testParseExampleWsdlAndCheckMatchingNames() + public function testParseExampleWSDLAndCheckMatchingNames() { // Constructor expects DOMDocument instance - $dom = $this->getWsdlExampleDom(); - $parser = new Zend_Soap_Wsdl_Parser($dom); + $dom = $this->getWSDLExampleDom(); + $parser = new WSDL\Parser($dom); $result = $parser->parse(); @@ -174,12 +180,13 @@ public function testParseExampleWsdlAndCheckMatchingNames() } } - public function testParseExampleWsdlWithDocumentationBlocks() + public function testParseExampleWSDLWithDocumentationBlocks() { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_documentation.wsdl")); - $parser = new Zend_Soap_Wsdl_Parser($dom); + $parser = new WSDL\Parser($dom); $result = $parser->parse(); } +*/ } diff --git a/test/WsdlTest.php b/test/WSDLTest.php similarity index 85% rename from test/WsdlTest.php rename to test/WSDLTest.php index 095a95d8..68ef8d44 100644 --- a/test/WsdlTest.php +++ b/test/WSDLTest.php @@ -21,7 +21,14 @@ */ /** - * Test cases for Zend_Soap_Wsdl + * @namespace + */ +namespace ZendTest\Soap; +use Zend\Soap\WSDL; +use Zend\Soap\WSDL\Strategy; + +/** + * Test cases for Zend_Soap_WSDL * * @category Zend * @package Zend_Soap @@ -29,11 +36,11 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_Wsdl + * @group Zend_Soap_WSDL */ -class Zend_Soap_WsdlTest extends PHPUnit_Framework_TestCase +class WSDLTest extends \PHPUnit_Framework_TestCase { - protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) + protected function sanitizeWSDLXmlOutputForOsCompability($xmlstring) { $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring); $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); @@ -49,9 +56,9 @@ public function swallowIncludeNotices($errno, $errstr) function testConstructor() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . '' ); } - function testSetUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes() + function testSetUriChangesDomDocumentWSDLStructureTnsAndTargetNamespaceAttributes() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->setUri('http://localhost/MyNewService.php'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'getType('int'); @@ -89,7 +96,7 @@ function testAddMessage() $wsdl->addMessage('myMessage', $messageParts); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); @@ -135,7 +142,7 @@ function testAddPortOperation() $wsdl->addPortOperation($portType, 'operation2', 'tns:operation2Request', 'tns:operation2Response'); $wsdl->addPortOperation($portType, 'operation3', 'tns:operation3Request', 'tns:operation3Response', 'tns:operation3Fault'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -200,7 +207,7 @@ function testAddBindingOperation() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -251,7 +258,7 @@ function testAddSoapBinding() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . '' . '' ); - $wsdl1 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl1 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); $wsdl1->addPortType('myPortType'); $binding = $wsdl1->addBinding('MyServiceBinding', 'myPortType'); @@ -289,7 +296,7 @@ function testAddSoapBinding() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl1->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl1->toXml()), '' . 'addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -331,7 +338,7 @@ function testAddSoapOperation() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addDocumentation($portType, 'This is a description for Port Type node.'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'getType('int'); @@ -435,15 +442,15 @@ public function testAddDocumentationToSetInsertsBefore() . '' . '' . '', - $this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()) + $this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()) ); } function testToXml() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . 'toDomDocument(); - $this->assertTrue($dom instanceOf DOMDocument); + $this->assertTrue($dom instanceOf \DOMDocument); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), '' . 'dump(); $wsdlDump = ob_get_clean(); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdlDump), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdlDump), '' . 'dump(dirname(__FILE__) . '/_files/dumped.wsdl'); $dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dumpedContent), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($dumpedContent), '' . 'assertEquals('xsd:string', $wsdl->getType('string'), 'xsd:string detection failed.'); $this->assertEquals('xsd:string', $wsdl->getType('str'), 'xsd:string detection failed.'); @@ -526,24 +533,24 @@ function testGetType() function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', true); - $this->assertEquals('tns:Zend_Soap_Wsdl_Test', $wsdl->getType('Zend_Soap_Wsdl_Test')); - $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_DefaultComplexType); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', true); + $this->assertEquals('tns:Zend_Soap_WSDL_Test', $wsdl->getType('Zend_Soap_WSDL_Test')); + $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', false); - $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_Wsdl_Test')); - $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType); + $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', false); + $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_WSDL_Test')); + $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } function testGetComplexTypeBasedOnStrategiesStringNames() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_DefaultComplexType'); - $this->assertEquals('tns:Zend_Soap_Wsdl_Test', $wsdl->getType('Zend_Soap_Wsdl_Test')); - $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_DefaultComplexType); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_DefaultComplexType'); + $this->assertEquals('tns:Zend_Soap_WSDL_Test', $wsdl->getType('Zend_Soap_WSDL_Test')); + $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_AnyType'); - $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_Wsdl_Test')); - $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_AnyType); + $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_AnyType'); + $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_WSDL_Test')); + $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } /** @@ -553,10 +560,10 @@ function testSettingUnknownStrategyThrowsException() { set_error_handler(array($this, 'swallowIncludeNotices'), E_WARNING); try { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', 'Zend_Soap_Wsdl_Strategy_UnknownStrategyType'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_UnknownStrategyType'); restore_error_handler(); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } restore_error_handler(); } @@ -564,10 +571,10 @@ function testSettingUnknownStrategyThrowsException() function testSettingInvalidStrategyObjectThrowsException() { try { - $strategy = new Zend_Soap_Wsdl_Test(); - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $strategy); + $strategy = new \Zend_Soap_WSDL_Test(); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', $strategy); $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { + } catch(WSDL\Exception $e) { } } @@ -575,34 +582,34 @@ function testSettingInvalidStrategyObjectThrowsException() function testAddingSameComplexTypeMoreThanOnceIsIgnored() { try { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - $wsdl->addType('Zend_Soap_Wsdl_Test'); - $wsdl->addType('Zend_Soap_Wsdl_Test'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl->addType('Zend_Soap_WSDL_Test'); + $wsdl->addType('Zend_Soap_WSDL_Test'); $types = $wsdl->getTypes(); $this->assertEquals(1, count($types)); - $this->assertEquals(array("Zend_Soap_Wsdl_Test"), $types); - } catch(Zend_Soap_Wsdl_Exception $e) { + $this->assertEquals(array("Zend_Soap_WSDL_Test"), $types); + } catch(WSDL\Exception $e) { $this->fail(); } } function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); - $this->assertEquals(array('Zend_Soap_Wsdl_Test'), $wsdl->getTypes()); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl->addComplexType('Zend_Soap_WSDL_Test'); + $this->assertEquals(array('Zend_Soap_WSDL_Test'), $wsdl->getTypes()); - $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); - $this->assertEquals(array('Zend_Soap_Wsdl_Test'), $wsdl->getTypes()); + $wsdl->addComplexType('Zend_Soap_WSDL_Test'); + $this->assertEquals(array('Zend_Soap_WSDL_Test'), $wsdl->getTypes()); } function testAddComplexType() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('Zend_Soap_Wsdl_Test'); + $wsdl->addComplexType('Zend_Soap_WSDL_Test'); - $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -629,7 +636,7 @@ function testAddComplexType() */ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() { - $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:string", $wsdl->getType("StrIng")); $this->assertEquals("xsd:string", $wsdl->getType("sTr")); @@ -644,8 +651,8 @@ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() */ public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceBySequenceStrategy() { - $wsdl = new Zend_Soap_Wsdl("MyService", "http://localhost/MyService.php"); - $wsdl->setComplexTypeStrategy(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence()); + $wsdl = new WSDL\WSDL("MyService", "http://localhost/MyService.php"); + $wsdl->setComplexTypeStrategy(new Strategy\ArrayOfTypeSequence()); $wsdl->addComplexType("string[]"); $wsdl->addComplexType("int[]"); @@ -664,7 +671,7 @@ public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceByS */ public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() { - $wsdl = new Zend_Soap_Wsdl("MyService", self::URI_WITH_EXPANDED_AMP); + $wsdl = new WSDL\WSDL("MyService", self::URI_WITH_EXPANDED_AMP); $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } @@ -673,7 +680,7 @@ public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() */ public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly() { - $wsdl = new Zend_Soap_Wsdl("MyService", "http://example.com"); + $wsdl = new WSDL\WSDL("MyService", "http://example.com"); $wsdl->setUri(self::URI_WITH_EXPANDED_AMP); $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } @@ -684,7 +691,7 @@ public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly() /** * Test Class */ -class Zend_Soap_Wsdl_Test { +class Test { /** * @var integer */ diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php deleted file mode 100644 index e3dbf8ca..00000000 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ /dev/null @@ -1,227 +0,0 @@ -strategy = new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex(); - $this->wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php', $this->strategy); - } - - public function testNestingObjectsDeepMakesNoSenseThrowingException() - { - try { - $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[][]'); - $this->fail(); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - public function testAddComplexTypeOfNonExistingClassThrowsException() - { - try { - $this->wsdl->addComplexType('Some_Soap_Wsdl_UnknownClass[]'); - } catch(Zend_Soap_Wsdl_Exception $e) { - - } - } - - /** - * @group ZF-5046 - */ - public function testArrayOfSimpleObject() - { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[]'); - $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexTest", $return); - - $wsdl = $this->wsdl->toXML(); - - $this->assertContains( - '', - $wsdl - ); - - $this->assertContains( - '', - $wsdl - ); - } - - public function testThatOverridingStrategyIsReset() - { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexTest[]'); - $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexTest", $return); - #$this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplexStrategy); - - $wsdl = $this->wsdl->toXML(); - } - - /** - * @group ZF-5046 - */ - public function testArrayOfComplexObjects() - { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectStructure[]'); - $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexObjectStructure", $return); - - $wsdl = $this->wsdl->toXML(); - - $this->assertContains( - '', - $wsdl - ); - - $this->assertContains( - '', - $wsdl - ); - } - - public function testArrayOfObjectWithObject() - { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); - $this->assertEquals("tns:ArrayOfZend_Soap_Wsdl_ComplexObjectWithObjectStructure", $return); - - $wsdl = $this->wsdl->toXML(); - - $this->assertContains( - '', - $wsdl - ); - - $this->assertContains( - '', - $wsdl - ); - - $this->assertContains( - '', - $wsdl - ); - } - - /** - * @group ZF-4937 - */ - public function testAddingTypesMultipleTimesIsSavedOnlyOnce() - { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); - - $wsdl = $this->wsdl->toXML(); - - $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]"') - ); - $this->assertEquals(1, - substr_count($wsdl, '') - ); - $this->assertEquals(1, - substr_count($wsdl, '') - ); - } - - /** - * @group ZF-4937 - */ - public function testAddingSingularThenArrayTypeIsRecognizedCorretly() - { - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure'); - $return = $this->wsdl->addComplexType('Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]'); - - $wsdl = $this->wsdl->toXML(); - - $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:Zend_Soap_Wsdl_ComplexObjectWithObjectStructure[]"') - ); - $this->assertEquals(1, - substr_count($wsdl, '') - ); - $this->assertEquals(1, - substr_count($wsdl, '') - ); - } - - /** - * @group ZF-5149 - */ - public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowingException() - { - try { - $return = $this->wsdl->addComplexType("Zend_Soap_Wsdl_ComplexTypeA"); - $wsdl = $this->wsdl->toXml(); - } catch(Exception $e) { - $this->fail("Adding object with nested structure should not throw exception."); - } - } - - /** - * @group ZF-5149 - */ - public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllTypesRecursivly() - { - $return = $this->wsdl->addComplexType("Zend_Soap_Wsdl_ComplexTypeA"); - $wsdl = $this->wsdl->toXml(); - - $this->assertEquals(1, - substr_count($wsdl, ''), - 'No definition of complex type A found.' - ); - $this->assertEquals(1, - substr_count($wsdl, ''), - 'No definition of complex type B array found.' - ); - $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:Zend_Soap_Wsdl_ComplexTypeB[]"'), - 'No usage of Complex Type B array found.' - ); - } - - /** - * @group ZF-5754 - */ - public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() - { - try { - $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - $this->assertEquals("Infinite recursion, cannot nest 'Zend_Soap_AutoDiscover_Recursion' into itself.", $e->getMessage()); - } - } -} diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php deleted file mode 100644 index bc18b931..00000000 --- a/test/Wsdl/CompositeStrategyTest.php +++ /dev/null @@ -1,140 +0,0 @@ -connectTypeToStrategy("Book", "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex"); - - $bookStrategy = $strategy->getStrategyOfType("Book"); - $cookieStrategy = $strategy->getStrategyOfType("Cookie"); - - $this->assertTrue( $bookStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex ); - $this->assertTrue( $cookieStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence ); - } - - public function testConstructorTypeMapSyntax() - { - $typeMap = array("Book" => "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex"); - - $strategy = new Zend_Soap_Wsdl_Strategy_Composite($typeMap, "Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence"); - - $bookStrategy = $strategy->getStrategyOfType("Book"); - $cookieStrategy = $strategy->getStrategyOfType("Cookie"); - - $this->assertTrue( $bookStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex ); - $this->assertTrue( $cookieStrategy instanceof Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence ); - } - - public function testCompositeThrowsExceptionOnInvalidType() - { - $strategy = new Zend_Soap_Wsdl_Strategy_Composite(); - try { - $strategy->connectTypeToStrategy(array(), "strategy"); - $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - } - } - - public function testCompositeThrowsExceptionOnInvalidStrategy() - { - $strategy = new Zend_Soap_Wsdl_Strategy_Composite(array(), "invalid"); - $strategy->connectTypeToStrategy("Book", "strategy"); - - try { - $book = $strategy->getStrategyOfType("Book"); - $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - } - - try { - $book = $strategy->getStrategyOfType("Anything"); - $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - } - } - - public function testCompositeDelegatesAddingComplexTypesToSubStrategies() - { - $strategy = new Zend_Soap_Wsdl_Strategy_Composite(array(), "Zend_Soap_Wsdl_Strategy_AnyType"); - $strategy->connectTypeToStrategy("Zend_Soap_Wsdl_Book", "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex"); - $strategy->connectTypeToStrategy("Zend_Soap_Wsdl_Cookie", "Zend_Soap_Wsdl_Strategy_DefaultComplexType"); - - $wsdl = new Zend_Soap_Wsdl("SomeService", "http://example.com"); - $strategy->setContext($wsdl); - - $this->assertEquals("tns:Zend_Soap_Wsdl_Book", $strategy->addComplexType("Zend_Soap_Wsdl_Book")); - $this->assertEquals("tns:Zend_Soap_Wsdl_Cookie", $strategy->addComplexType("Zend_Soap_Wsdl_Cookie")); - $this->assertEquals("xsd:anyType", $strategy->addComplexType("Zend_Soap_Wsdl_Anything")); - } - - public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrowsException() - { - $strategy = new Zend_Soap_Wsdl_Strategy_Composite(); - try { - $strategy->addComplexType("Test"); - $this->fail(); - } catch(Exception $e) { - $this->assertTrue($e instanceof Zend_Soap_Wsdl_Exception); - } - } -} - -class Zend_Soap_Wsdl_Book -{ - /** - * @var int - */ - public $somevar; -} -class Zend_Soap_Wsdl_Cookie -{ - /** - * @var int - */ - public $othervar; -} -class Zend_Soap_Wsdl_Anything -{ -} diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index b93ddfdd..57980450 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -20,6 +20,11 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\_files; + /* Test Functions */ /** @@ -28,7 +33,7 @@ * @param string $arg * @return string */ -function Zend_Soap_AutoDiscover_TestFunc($who) +function TestFunc($who) { return "Hello $who"; } @@ -36,7 +41,7 @@ function Zend_Soap_AutoDiscover_TestFunc($who) /** * Test Function 2 */ -function Zend_Soap_AutoDiscover_TestFunc2() +function TestFunc2() { return "Hello World"; } @@ -46,7 +51,7 @@ function Zend_Soap_AutoDiscover_TestFunc2() * * @return bool */ -function Zend_Soap_AutoDiscover_TestFunc3() +function TestFunc3() { return false; } @@ -56,7 +61,7 @@ function Zend_Soap_AutoDiscover_TestFunc3() * * @return bool */ -function Zend_Soap_AutoDiscover_TestFunc4() +function TestFunc4() { return true; } @@ -66,7 +71,7 @@ function Zend_Soap_AutoDiscover_TestFunc4() * * @return int */ -function Zend_Soap_AutoDiscover_TestFunc5() +function TestFunc5() { return 123; } @@ -76,7 +81,7 @@ function Zend_Soap_AutoDiscover_TestFunc5() * * @return string */ -function Zend_Soap_AutoDiscover_TestFunc6() +function TestFunc6() { return "string"; } @@ -86,7 +91,7 @@ function Zend_Soap_AutoDiscover_TestFunc6() * * @return array */ -function Zend_Soap_AutoDiscover_TestFunc7() +function TestFunc7() { return array('foo' => 'bar', 'baz' => true, 1 => false, 'bat' => 123); } @@ -96,7 +101,7 @@ function Zend_Soap_AutoDiscover_TestFunc7() * * @return StdClass */ -function Zend_Soap_AutoDiscover_TestFunc8() +function TestFunc8() { $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false); return $return; @@ -109,7 +114,7 @@ function Zend_Soap_AutoDiscover_TestFunc8() * @param string $bar * @return string */ -function Zend_Soap_AutoDiscover_TestFunc9($foo, $bar) +function TestFunc9($foo, $bar) { return "$foo $bar"; } @@ -121,7 +126,7 @@ function Zend_Soap_AutoDiscover_TestFunc9($foo, $bar) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes +class TestFixingMultiplePrototypes { /** * Test function @@ -144,7 +149,7 @@ function testFunc($a=100, $b=200, $d=300) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_Test { +class Test { /** * Test Function 1 * @@ -189,7 +194,7 @@ static function testFunc4() } } -class Zend_Soap_AutoDiscoverTestClass1 +class AutoDiscoverTestClass1 { /** * @var integer $var @@ -209,31 +214,31 @@ class Zend_Soap_AutoDiscoverTestClass1 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscoverTestClass2 +class AutoDiscoverTestClass2 { /** * - * @param Zend_Soap_AutoDiscoverTestClass1 $test + * @param \ZendTest\Soap\_files\AutoDiscoverTestClass1 $test * @return boolean */ - public function add(Zend_Soap_AutoDiscoverTestClass1 $test) + public function add(AutoDiscoverTestClass1 $test) { return true; } /** - * @return Zend_Soap_AutoDiscoverTestClass1[] + * @return \ZendTest\Soap\_files\AutoDiscoverTestClass1[] */ public function fetchAll() { return array( - new Zend_Soap_AutoDiscoverTestClass1(), - new Zend_Soap_AutoDiscoverTestClass1(), + new AutoDiscoverTestClass1(), + new AutoDiscoverTestClass1(), ); } /** - * @param Zend_Soap_AutoDiscoverTestClass1[] + * @param \ZendTest\Soap\_files\AutoDiscoverTestClass1[] */ public function addMultiple($test) { @@ -248,7 +253,7 @@ public function addMultiple($test) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexTypeB +class ComplexTypeB { /** * @var string @@ -267,10 +272,10 @@ class Zend_Soap_Wsdl_ComplexTypeB * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexTypeA +class ComplexTypeA { /** - * @var Zend_Soap_Wsdl_ComplexTypeB[] + * @var \ZendTest\Soap\_files\ComplexTypeB[] */ public $baz = array(); } @@ -282,7 +287,7 @@ class Zend_Soap_Wsdl_ComplexTypeA * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexTest +class ComplexTest { /** * @var int @@ -297,7 +302,7 @@ class Zend_Soap_Wsdl_ComplexTest * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexObjectStructure +class ComplexObjectStructure { /** * @var boolean @@ -327,10 +332,10 @@ class Zend_Soap_Wsdl_ComplexObjectStructure * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure +class ComplexObjectWithObjectStructure { /** - * @var Zend_Soap_Wsdl_ComplexTest + * @var \ZendTest\Soap\_files\ComplexTest */ public $object; } @@ -342,24 +347,24 @@ class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_MyService +class MyService { /** * @param string $foo - * @return Zend_Soap_AutoDiscover_MyResponse[] + * @return \ZendTest\Soap\_files\MyResponse[] */ public function foo($foo) { } /** * @param string $bar - * @return Zend_Soap_AutoDiscover_MyResponse[] + * @return \ZendTest\Soap\_files\MyResponse[] */ public function bar($bar) { } /** * @param string $baz - * @return Zend_Soap_AutoDiscover_MyResponse[] + * @return \ZendTest\Soap\_files\MyResponse[] */ public function baz($baz) { } @@ -372,7 +377,7 @@ public function baz($baz) { * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_MyServiceSequence +class MyServiceSequence { /** * @param string $foo @@ -409,7 +414,7 @@ public function bazNested($baz) { * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_MyResponse +class MyResponse { /** * @var string @@ -424,10 +429,10 @@ class Zend_Soap_AutoDiscover_MyResponse * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_Recursion +class Recursion { /** - * @var Zend_Soap_AutoDiscover_Recursion + * @var \ZendTest\Soap\_files\Recursion */ public $recursion; } @@ -435,7 +440,7 @@ class Zend_Soap_AutoDiscover_Recursion /** * @param string $message */ -function Zend_Soap_AutoDiscover_OneWay($message) +function OneWay($message) { } @@ -447,7 +452,7 @@ function Zend_Soap_AutoDiscover_OneWay($message) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_AutoDiscover_NoReturnType +class NoReturnType { /** * diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php index dfed208f..9bf9bf93 100644 --- a/test/_files/fulltests/server1.php +++ b/test/_files/fulltests/server1.php @@ -20,6 +20,10 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\_files\fulltests; /** * @category Zend @@ -28,22 +32,22 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Service_Server1 +class Server1 { /** - * @param Zend_Soap_Wsdl_ComplexTypeB - * @return Zend_Soap_Wsdl_ComplexTypeA[] + * @param \ZendTest\Soap\_files\fulltests\ComplexTypeB + * @return \ZendTest\Soap\_files\fulltests\ComplexTypeA[] */ public function request($request) { - $a = new Zend_Soap_Wsdl_ComplexTypeA(); + $a = new ComplexTypeA(); - $b1 = new Zend_Soap_Wsdl_ComplexTypeB(); + $b1 = new ComplexTypeB(); $b1->bar = "bar"; $b1->foo = "bar"; $a->baz[] = $b1; - $b2 = new Zend_Soap_Wsdl_ComplexTypeB(); + $b2 = new ComplexTypeB(); $b2->bar = "foo"; $b2->foo = "foo"; $a->baz[] = $b2; @@ -61,7 +65,7 @@ public function request($request) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexTypeB +class ComplexTypeB { /** * @var string @@ -80,19 +84,19 @@ class Zend_Soap_Wsdl_ComplexTypeB * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexTypeA +class ComplexTypeA { /** - * @var Zend_Soap_Wsdl_ComplexTypeB[] + * @var \ZendTest\Soap\_files\fulltests\ComplexTypeB[] */ public $baz = array(); } if(isset($_GET['wsdl'])) { - $server = new Zend_Soap_AutoDiscover(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex()); + $server = new \Zend\Soap\AutoDiscover\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; - $server = new Zend_Soap_Server($uri); + $server = new \Zend\Soap\Server\Server($uri); } -$server->setClass('Zend_Soap_Service_Server1'); +$server->setClass('\ZendTest\Soap\_files\fulltests\Server1'); $server->handle(); diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index e321d49b..daea8e47 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -20,6 +20,10 @@ * @version $Id$ */ +/** + * @namespace + */ +namespace ZendTest\Soap\_files\fulltests; /** * @category Zend @@ -28,7 +32,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Wsdl_ComplexTypeB +class ComplexTypeB { /** * @var string @@ -47,16 +51,16 @@ class Zend_Soap_Wsdl_ComplexTypeB * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Soap_Service_Server2 +class Server2 { /** * @param string $foo * @param string $bar - * @return Zend_Soap_Wsdl_ComplexTypeB + * @return \ZendTest\Soap\_files\fulltests\ComplexTypeB */ public function request($foo, $bar) { - $b = new Zend_Soap_Wsdl_ComplexTypeB(); + $b = new ComplexTypeB(); $b->bar = $bar; $b->foo = $foo; return $b; @@ -64,10 +68,10 @@ public function request($foo, $bar) } if(isset($_GET['wsdl'])) { - $server = new Zend_Soap_AutoDiscover(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex()); + $server = new \Zend\Soap\AutoDiscover\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; - $server = new Zend_Soap_Server($uri); + $server = new \Zend\Soap\Server\Server($uri); } -$server->setClass('Zend_Soap_Service_Server2'); +$server->setClass('ZendTest\Soap\_files\fulltests\Server2'); $server->handle(); From ccd4d4e2778f06d38286c11348c4e9b3d25ef3ec Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Sat, 3 Jul 2010 23:40:03 -0400 Subject: [PATCH 044/123] Zend\Server cleanup - Renamed Zend\Server\ServerInterface to simply Zend\Server\Server - Updated code and tests to reflect the above --- src/AutoDiscover/AutoDiscover.php | 4 ++-- src/Server/Server.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AutoDiscover/AutoDiscover.php b/src/AutoDiscover/AutoDiscover.php index b3f1b03b..9fae7e8d 100644 --- a/src/AutoDiscover/AutoDiscover.php +++ b/src/AutoDiscover/AutoDiscover.php @@ -31,7 +31,7 @@ * \Zend\Soap\AutoDiscover\AutoDiscover * * @uses \Zend\Server\AbstractServer - * @uses \Zend\Server\ServerInterface + * @uses \Zend\Server\Server * @uses \Zend\Server\Reflection\Reflection * @uses \Zend\Soap\AutoDiscover\Exception * @uses \Zend\Soap\WSDL\WSDL @@ -40,7 +40,7 @@ * @package Zend_Soap * @subpackage AutoDiscover */ -class AutoDiscover implements \Zend\Server\ServerInterface +class AutoDiscover implements \Zend\Server\Server { /** * @var \Zend\Soap\WSDL\WSDL diff --git a/src/Server/Server.php b/src/Server/Server.php index ff119235..b5ad707c 100644 --- a/src/Server/Server.php +++ b/src/Server/Server.php @@ -30,7 +30,7 @@ * @uses DOMDocument * @uses SoapFault * @uses SoapServer - * @uses \Zend\Server\ServerInterface + * @uses \Zend\Server\Server * @uses \Zend\Soap\Server\Exception * @category Zend * @package Zend_Soap @@ -39,7 +39,7 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -class Server implements \Zend\Server\ServerInterface +class Server implements \Zend\Server\Server { /** * Actor URI From 8346337cdccfa910ccfd1a0b6f21f8cbe991d08b Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 6 Jul 2010 08:15:28 -0400 Subject: [PATCH 045/123] Zend\Soap cleanup - Fixed test suite so that it now works --- src/WSDL/WSDL.php | 22 +- test/AutoDiscover/OnlineTest.php | 6 +- test/AutoDiscoverTest.php | 320 +++++++++--------- test/ClientTest.php | 222 ++---------- test/ServerTest.php | 291 +++------------- test/TestAsset/WSDLTestClass.php | 16 + test/{_files => TestAsset}/cert_file | 0 test/{_files => TestAsset}/commontypes.php | 243 +++++++++++-- .../fulltests/server1.php | 0 .../fulltests/server2.php | 0 .../wsdl_documentation.wsdl | 0 test/TestAsset/wsdl_example.wsdl | 2 + test/WSDL/ArrayOfTypeComplexStrategyTest.php | 92 +++-- test/WSDL/ArrayOfTypeSequenceStrategyTest.php | 11 +- test/WSDL/DefaultComplexTypeTest.php | 2 +- test/WSDL/ElementTest.php | 2 - test/WSDL/ParserTest.php | 10 +- test/WSDLTest.php | 55 ++- test/_files/wsdl_example.wsdl | 2 - 19 files changed, 559 insertions(+), 737 deletions(-) create mode 100644 test/TestAsset/WSDLTestClass.php rename test/{_files => TestAsset}/cert_file (100%) rename test/{_files => TestAsset}/commontypes.php (62%) rename test/{_files => TestAsset}/fulltests/server1.php (100%) rename test/{_files => TestAsset}/fulltests/server2.php (100%) rename test/{_files => TestAsset}/wsdl_documentation.wsdl (100%) create mode 100644 test/TestAsset/wsdl_example.wsdl delete mode 100644 test/_files/wsdl_example.wsdl diff --git a/src/WSDL/WSDL.php b/src/WSDL/WSDL.php index b0788d0e..19b929fe 100644 --- a/src/WSDL/WSDL.php +++ b/src/WSDL/WSDL.php @@ -23,7 +23,7 @@ * @namespace */ namespace Zend\Soap\WSDL; -use Zend\URI; +use Zend\URI\URL; /** * \Zend\Soap\WSDL\WSDL @@ -79,13 +79,13 @@ class WSDL * Constructor * * @param string $name Name of the Web Service being Described - * @param string|\Zend\URI\URL $uri URI where the WSDL will be available + * @param string|\Zend\URL $uri URI where the WSDL will be available * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy */ public function __construct($name, $uri, $strategy = true) { - if ($uri instanceof URI\URL) { - $uri = $uri->getUri(); + if ($uri instanceof URL) { + $uri = $uri->generate(); } $this->_uri = $uri; @@ -114,13 +114,13 @@ public function __construct($name, $uri, $strategy = true) /** * Set a new uri for this WSDL * - * @param string|\Zend\URI\URL $uri + * @param string|\Zend\URL $uri * @return \Zend\Server\WSDL\WSDL */ public function setUri($uri) { - if ($uri instanceof URI\URL) { - $uri = $uri->getUri(); + if ($uri instanceof URL) { + $uri = $uri->generate(); } $oldUri = $this->_uri; $this->_uri = $uri; @@ -361,8 +361,8 @@ public function addSoapBinding($binding, $style = 'document', $transport = 'http */ public function addSoapOperation($binding, $soap_action) { - if ($soap_action instanceof URI\URL) { - $soap_action = $soap_action->getUri(); + if ($soap_action instanceof URL) { + $soap_action = $soap_action->generate(); } $soap_operation = $this->_dom->createElement('soap:operation'); $soap_operation->setAttribute('soapAction', $soap_action); @@ -383,8 +383,8 @@ public function addSoapOperation($binding, $soap_action) */ public function addService($name, $port_name, $binding, $location) { - if ($location instanceof URI\URL) { - $location = $location->getUri(); + if ($location instanceof URL) { + $location = $location->generate(); } $service = $this->_dom->createElement('service'); $service->setAttribute('name', $name); diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index e922ad13..1fb221e1 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -24,9 +24,9 @@ * @namespace */ namespace ZendTest\Soap\AutoDiscover; -use Zend\Soap\Client; +require_once __DIR__ . '/../TestAsset/commontypes.php'; -/** Zend_Soap_Server */ +use Zend\Soap\Client; /** * @category Zend @@ -52,7 +52,7 @@ public function testNestedObjectArrayResponse() { $wsdl = $this->baseuri."/server1.php?wsdl"; - $b = new \ZendTest\Soap\_files\ComplexTypeB(); + $b = new \ZendTest_Soap_TestAsset_ComplexTypeB(); $b->bar = "test"; $b->foo = "test"; diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 24865fbb..d2baf5d8 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -24,12 +24,14 @@ * @namespace */ namespace ZendTest\Soap; -use Zend\Soap\AutoDiscover; - -/** PHPUnit Test Case */ /** Include Common TestTypes */ -require_once '_files/commontypes.php'; +require_once 'TestAsset/commontypes.php'; + +use Zend\Soap\AutoDiscover\AutoDiscover, + Zend\Soap\AutoDiscover\Exception as AutoDiscoverException; + +/** PHPUnit Test Case */ /** * Test cases for Zend_Soap_AutoDiscover @@ -67,8 +69,8 @@ function testSetClass() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->setClass('\ZendTest\Soap\_files\Test'); + $server = new AutoDiscover(); + $server->setClass('ZendTest_Soap_TestAsset_Test'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -81,12 +83,12 @@ function testSetClass() . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' - . 'name="Zend_Soap_AutoDiscover_Test" ' + . 'name="ZendTest_Soap_TestAsset_Test" ' . 'targetNamespace="' . $scriptUri . '">' . '' . '' . '' - . '' + . '' . '' . 'Test Function 1' . '' @@ -107,7 +109,7 @@ function testSetClass() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -130,8 +132,8 @@ function testSetClass() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -145,21 +147,21 @@ function testSetClass() . '' . ''; - $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); + $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(dirname(__FILE__).'/_files/setclass.wsdl'); + unlink(__DIR__.'/TestAsset/setclass.wsdl'); } function testSetClassWithDifferentStyles() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); + $server = new AutoDiscover(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); - $server->setClass('Zend_Soap_AutoDiscover_Test'); + $server->setClass('ZendTest_Soap_TestAsset_Test'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -172,7 +174,7 @@ function testSetClassWithDifferentStyles() . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' - . 'name="Zend_Soap_AutoDiscover_Test" ' + . 'name="ZendTest_Soap_TestAsset_Test" ' . 'targetNamespace="' . $scriptUri . '">' . '' . '' @@ -227,7 +229,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . 'Test Function 1' . '' @@ -248,7 +250,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -271,8 +273,8 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -302,11 +304,11 @@ function testSetClassWithDifferentStyles() . '' . ''; - $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); + $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(dirname(__FILE__).'/_files/setclass.wsdl'); + unlink(__DIR__.'/TestAsset/setclass.wsdl'); } /** @@ -316,20 +318,20 @@ function testSetClassWithResponseReturnPartCompabilityMode() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->setClass('Zend_Soap_AutoDiscover_Test'); + $server = new AutoDiscover(); + $server->setClass('ZendTest_Soap_TestAsset_Test'); $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); - $dom->save(dirname(__FILE__).'/_files/setclass.wsdl'); + $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); - unlink(dirname(__FILE__).'/_files/setclass.wsdl'); + unlink(__DIR__.'/TestAsset/setclass.wsdl'); } @@ -337,13 +339,13 @@ function testAddFunctionSimple() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server = new AutoDiscover(); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); - $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); + $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -352,12 +354,12 @@ function testAddFunctionSimple() ''. ''. ''. - 'Test Function'. + 'Test Function'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -367,28 +369,28 @@ function testAddFunctionSimple() ''. ''. ''. - ''. - ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); + unlink(__DIR__.'/TestAsset/addfunction.wsdl'); } function testAddFunctionSimpleWithDifferentStyle() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); + $server = new AutoDiscover(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); - $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); + $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -397,17 +399,17 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - 'Test Function'. + 'Test Function'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -417,13 +419,13 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''. - ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); + unlink(__DIR__.'/TestAsset/addfunction.wsdl'); } /** @@ -433,44 +435,44 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server = new AutoDiscover(); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); - $dom->save(dirname(__FILE__).'/_files/addfunction.wsdl'); + $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; $wsdl = $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()); - $this->assertContains('', $wsdl); - $this->assertNotContains('assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + $this->assertContains('', $wsdl); + $this->assertNotContains('assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(dirname(__FILE__).'/_files/addfunction.wsdl'); + unlink(__DIR__.'/TestAsset/addfunction.wsdl'); } function testAddFunctionMultiple() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc2'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc3'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc4'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc5'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc6'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc7'); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc9'); + $server = new AutoDiscover(); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc2'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc3'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc4'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc5'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc6'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc7'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc9'); $dom = new \DOMDocument(); ob_start(); $server->handle(); $dom->loadXML(ob_get_clean()); - $dom->save(dirname(__FILE__).'/_files/addfunction2.wsdl'); + $dom->save(__DIR__.'/TestAsset/addfunction2.wsdl'); $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; @@ -479,54 +481,54 @@ function testAddFunctionMultiple() ''. ''. ''. - 'Test Function'. - 'Test Function 2'. - 'Return false'. - 'Return true'. - 'Return integer'. - 'Return string'. - 'Return array'. - 'Multiple Args'. + 'Test Function'. + 'Test Function 2'. + 'Return false'. + 'Return true'. + 'Return integer'. + 'Return string'. + 'Return array'. + 'Multiple Args'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -536,28 +538,28 @@ function testAddFunctionMultiple() ''. ''. ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); - $this->assertTrue($dom->schemaValidate(dirname(__FILE__) .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(dirname(__FILE__).'/_files/addfunction2.wsdl'); + unlink(__DIR__.'/TestAsset/addfunction2.wsdl'); } /** @@ -568,8 +570,8 @@ public function testUseHttpsSchemaIfAccessedThroughHttps() $_SERVER['HTTPS'] = "on"; $httpsScriptUri = 'https://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server = new AutoDiscover(); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); ob_start(); $server->handle(); @@ -585,8 +587,8 @@ public function testChangeWSDLUriInConstructor() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(true, "http://example.com/service.php"); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server = new AutoDiscover(true, "http://example.com/service.php"); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); ob_start(); $server->handle(); @@ -603,9 +605,9 @@ public function testChangeWSDLUriViaSetUri() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(true); + $server = new AutoDiscover(true); $server->setUri("http://example.com/service.php"); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); ob_start(); $server->handle(); @@ -617,11 +619,11 @@ public function testChangeWSDLUriViaSetUri() public function testSetNonStringNonZendUriUriThrowsException() { - $server = new AutoDiscover\AutoDiscover(); + $server = new AutoDiscover(); try { $server->setUri(array("bogus")); $this->fail(); - } catch(AutoDiscover\Exception $e) { + } catch(AutoDiscoverException $e) { } } @@ -633,9 +635,9 @@ public function testChangingWSDLUriAfterGenerationIsPossible() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(true); + $server = new AutoDiscover(true); $server->setUri("http://example.com/service.php"); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); ob_start(); $server->handle(); @@ -664,8 +666,8 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWSDL() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover\AutoDiscover(); - $server->setClass('Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes'); + $server = new AutoDiscover(); + $server->setClass('ZendTest_Soap_TestAsset_TestFixingMultiplePrototypes'); ob_start(); $server->handle(); @@ -677,38 +679,38 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWSDL() public function testUnusedFunctionsOfAutoDiscoverThrowException() { - $server = new AutoDiscover\AutoDiscover(); + $server = new AutoDiscover(); try { $server->setPersistence("bogus"); $this->fail(); - } catch(AutoDiscover\Exception $e) { + } catch(AutoDiscoverException $e) { } try { $server->fault(); $this->fail(); - } catch(AutoDiscover\Exception $e) { + } catch(AutoDiscoverException $e) { } try { $server->loadFunctions("bogus"); $this->fail(); - } catch(AutoDiscover\Exception $e) { + } catch(AutoDiscoverException $e) { } } public function testGetFunctions() { - $server = new AutoDiscover\AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); - $server->setClass('Zend_Soap_AutoDiscover_Test'); + $server = new AutoDiscover(); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->setClass('ZendTest_Soap_TestAsset_Test'); $functions = $server->getFunctions(); $this->assertEquals( - array('Zend_Soap_AutoDiscover_TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'), + array('ZendTest_Soap_TestAsset_TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'), $functions ); } @@ -720,29 +722,29 @@ public function testUsingRequestUriWithoutParametersAsDefault() { // Apache $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost'); - $server = new AutoDiscover\AutoDiscover(); - $uri = $server->getUri()->getUri(); + $server = new AutoDiscover(); + $uri = $server->getUri()->generate(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("http://localhost/my_script.php", $uri); // Apache plus SSL $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on'); - $server = new AutoDiscover\AutoDiscover(); - $uri = $server->getUri()->getUri(); + $server = new AutoDiscover(); + $uri = $server->getUri()->generate(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("https://localhost/my_script.php", $uri); // IIS 5 + PHP as FastCGI $_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); - $server = new AutoDiscover\AutoDiscover(); - $uri = $server->getUri()->getUri(); + $server = new AutoDiscover(); + $uri = $server->getUri()->generate(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("http://localhost/my_script.php", $uri); // IIS $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); - $server = new AutoDiscover\AutoDiscover(); - $uri = $server->getUri()->getUri(); + $server = new AutoDiscover(); + $uri = $server->getUri()->generate(); $this->assertNotContains("?wsdl", $uri); $this->assertEquals("http://localhost/my_script.php", $uri); } @@ -752,27 +754,27 @@ public function testUsingRequestUriWithoutParametersAsDefault() */ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() { - $server = new AutoDiscover\AutoDiscover('Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex'); - $server->setClass('Zend_Soap_AutoDiscoverTestClass2'); + $server = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $server->setClass('ZendTest_Soap_TestAsset_AutoDiscoverTestClass2'); ob_start(); $server->handle(); $wsdlOutput = ob_get_clean(); $this->assertEquals(1, - substr_count($wsdlOutput, 'wsdl:arrayType="tns:Zend_Soap_AutoDiscoverTestClass1[]"'), + substr_count($wsdlOutput, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_AutoDiscoverTestClass1[]"'), 'wsdl:arrayType definition of TestClass1 has to occour once.' ); $this->assertEquals(1, - substr_count($wsdlOutput, ''), + substr_count($wsdlOutput, ''), 'Zend_Soap_AutoDiscoverTestClass1 has to be defined once.' ); $this->assertEquals(1, - substr_count($wsdlOutput, ''), + substr_count($wsdlOutput, ''), 'ArrayOfZend_Soap_AutoDiscoverTestClass1 should be defined once.' ); $this->assertTrue( - substr_count($wsdlOutput, '') >= 1, + substr_count($wsdlOutput, '') >= 1, 'Zend_Soap_AutoDiscoverTestClass1 appears once or more than once in the message parts section.' ); } @@ -782,8 +784,8 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() */ public function testDumpOrXmlOfAutoDiscover() { - $server = new AutoDiscover\AutoDiscover(); - $server->addFunction('Zend_Soap_AutoDiscover_TestFunc'); + $server = new AutoDiscover(); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); ob_start(); $server->handle(); @@ -809,19 +811,19 @@ public function testDumpOrXmlOfAutoDiscover() */ public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWSDL() { - $server = new AutoDiscover\AutoDiscover(); + $server = new AutoDiscover(); try { $server->dump(false); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof AutoDiscover\Exception); + $this->assertTrue($e instanceof AutoDiscoverException); } try { $server->toXml(); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof AutoDiscover\Exception); + $this->assertTrue($e instanceof AutoDiscoverException); } } @@ -830,11 +832,11 @@ public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWSDL() */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex() { - $autodiscover = new AutoDiscover\AutoDiscover('Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex'); - $autodiscover->setClass('Zend_Soap_AutoDiscover_MyService'); + $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $autodiscover->setClass('ZendTest_Soap_TestAsset_MyService'); $wsdl = $autodiscover->toXml(); - $this->assertEquals(1, substr_count($wsdl, '')); + $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(0, substr_count($wsdl, 'tns:My_Response[]')); } @@ -844,8 +846,8 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayC */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence() { - $autodiscover = new AutoDiscover\AutoDiscover('Zend_Soap_WSDL_Strategy_ArrayOfTypeSequence'); - $autodiscover->setClass('Zend_Soap_AutoDiscover_MyServiceSequence'); + $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence'); + $autodiscover->setClass('ZendTest_Soap_TestAsset_MyServiceSequence'); $wsdl = $autodiscover->toXml(); $this->assertEquals(1, substr_count($wsdl, '')); @@ -860,10 +862,10 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayS */ public function testAmpersandInUrlIsCorrectlyEncoded() { - $autodiscover = new AutoDiscover\AutoDiscover(); + $autodiscover = new AutoDiscover(); $autodiscover->setUri("http://example.com/?a=b&b=c"); - $autodiscover->setClass("Zend_Soap_AutoDiscover_Test"); + $autodiscover->setClass("ZendTest_Soap_TestAsset_Test"); $wsdl = $autodiscover->toXml(); $this->assertContains("http://example.com/?a=b&b=c", $wsdl); @@ -874,8 +876,8 @@ public function testAmpersandInUrlIsCorrectlyEncoded() */ public function testNoReturnIsOneWayCallInSetClass() { - $autodiscover = new AutoDiscover\AutoDiscover(); - $autodiscover->setClass('Zend_Soap_AutoDiscover_NoReturnType'); + $autodiscover = new AutoDiscover(); + $autodiscover->setClass('ZendTest_Soap_TestAsset_NoReturnType'); $wsdl = $autodiscover->toXml(); $this->assertContains( @@ -889,12 +891,12 @@ public function testNoReturnIsOneWayCallInSetClass() */ public function testNoReturnIsOneWayCallInAddFunction() { - $autodiscover = new AutoDiscover\AutoDiscover(); - $autodiscover->addFunction('Zend_Soap_AutoDiscover_OneWay'); + $autodiscover = new AutoDiscover(); + $autodiscover->addFunction('ZendTest_Soap_TestAsset_OneWay'); $wsdl = $autodiscover->toXml(); $this->assertContains( - '@param string $message', + '@param string $message', $wsdl ); } diff --git a/test/ClientTest.php b/test/ClientTest.php index 9ba2d3d7..5dc82941 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -24,20 +24,11 @@ * @namespace */ namespace ZendTest\Soap; -use Zend\Soap\Client; -use Zend\Soap\Server; - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Zend_Soap_ClientTest::main'); -} - - -/** PHPUnit Test Case */ -/** Zend_Soap_Server */ - -/** Zend_Soap_Client */ +require_once __DIR__ . '/TestAsset/commontypes.php'; +use Zend\Soap\Client; +use Zend\Soap\Server; /** * @category Zend @@ -79,8 +70,8 @@ public function testSetOptions() $ctx = stream_context_create(); $nonWSDLOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -95,7 +86,7 @@ public function testSetOptions() 'proxy_login' => 'proxy_login', 'proxy_password' => 'proxy_password', - 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'local_cert' => __DIR__.'/TestAsset/cert_file', 'passphrase' => 'some pass phrase', 'stream_context' => $ctx, @@ -116,9 +107,9 @@ public function testSetOptions() $this->assertTrue($client1->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); $wsdlOptions = array('soap_version' => SOAP_1_1, - 'wsdl' => dirname(__FILE__).'/_files/wsdl_example.wsdl', - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'wsdl' => __DIR__.'/TestAsset/wsdl_example.wsdl', + 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), 'encoding' => 'ISO-8859-1', 'login' => 'http_login', @@ -129,7 +120,7 @@ public function testSetOptions() 'proxy_login' => 'proxy_login', 'proxy_password' => 'proxy_password', - 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'local_cert' => __DIR__.'/TestAsset/cert_file', 'passphrase' => 'some pass phrase', 'stream_context' => $ctx, @@ -147,10 +138,10 @@ public function testGetOptions() $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); $options = array('soap_version' => SOAP_1_1, - 'wsdl' => dirname(__FILE__).'/_files/wsdl_example.wsdl', + 'wsdl' => __DIR__.'/TestAsset/wsdl_example.wsdl', - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -165,7 +156,7 @@ public function testGetOptions() 'proxy_login' => 'proxy_login', 'proxy_password' => 'proxy_password', - 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'local_cert' => __DIR__.'/TestAsset/cert_file', 'passphrase' => 'some pass phrase', 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5); @@ -227,12 +218,12 @@ public function testUserAgentAllowsEmptyString() public function testGetFunctions() { - $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); + $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server->setClass('ZendTest_Soap_TestAsset_TestClass'); - $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); - $this->assertTrue($client->getFunctions() == array('string testFunc1()', + $this->assertTrue($client->getFunctions() == array('string testFunc()', 'string testFunc2(string $who)', 'string testFunc3(string $who, int $when)', 'string testFunc4()')); @@ -256,10 +247,10 @@ public function testGetLastRequest() return; } - $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); + $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server->setClass('ZendTest_Soap_TestAsset_TestClass'); - $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); // Perform request $client->testFunc2('World'); @@ -286,10 +277,10 @@ public function testGetLastResponse() return; } - $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); + $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server->setClass('ZendTest_Soap_TestAsset_TestClass'); - $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); // Perform request $client->testFunc2('World'); @@ -317,10 +308,10 @@ public function testCallInvoke() return; } - $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); + $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server->setClass('ZendTest_Soap_TestAsset_TestClass'); - $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); $this->assertEquals($client->testFunc2('World'), 'Hello World!'); } @@ -330,8 +321,8 @@ public function testSetOptionsWithZendConfig() $ctx = stream_context_create(); $nonWSDLOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'Zend_Soap_Client_TestData1', - 'TestData2' => 'Zend_Soap_Client_TestData2',), + 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -346,7 +337,7 @@ public function testSetOptionsWithZendConfig() 'proxy_login' => 'proxy_login', 'proxy_password' => 'proxy_password', - 'local_cert' => dirname(__FILE__).'/_files/cert_file', + 'local_cert' => __DIR__.'/TestAsset/cert_file', 'passphrase' => 'some pass phrase', 'stream_context' => $ctx, @@ -368,10 +359,10 @@ public function testSetInputHeaders() return; } - $server = new Server\Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl'); - $server->setClass('Zend_Soap_Client_TestClass'); + $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server->setClass('ZendTest_Soap_TestAsset_TestClass'); - $client = new Client\Local($server, dirname(__FILE__) . '/_files/wsdl_example.wsdl'); + $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); // Add request header $client->addSoapInputHeader(new \SoapHeader('http://www.example.com/namespace', 'MyHeader1', 'SOAP header content 1')); @@ -483,150 +474,3 @@ public function testSetSoapClient() $this->assertSame($clientMock, $soap->getSoapClient()); } } - - -/** Test Class */ -class TestClass { - /** - * Test Function 1 - * - * @return string - */ - function testFunc1() - { - return "Hello World"; - } - - /** - * Test Function 2 - * - * @param string $who Some Arg - * @return string - */ - function testFunc2($who) - { - return "Hello $who!"; - } - - /** - * Test Function 3 - * - * @param string $who Some Arg - * @param int $when Some - * @return string - */ - function testFunc3($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 4 - * - * @return string - */ - static function testFunc4() - { - return "I'm Static!"; - } -} - -/** Test class 2 */ -class TestData1 { - /** - * Property1 - * - * @var string - */ - public $property1; - - /** - * Property2 - * - * @var float - */ - public $property2; -} - -/** Test class 2 */ -class TestData2 { - /** - * Property1 - * - * @var integer - */ - public $property1; - - /** - * Property1 - * - * @var float - */ - public $property2; -} - - -/* Test Functions */ - -/** - * Test Function - * - * @param string $arg - * @return string - */ -function Zend_Soap_Client_TestFunc1($who) -{ - return "Hello $who"; -} - -/** - * Test Function 2 - */ -function Zend_Soap_Client_TestFunc2() -{ - return "Hello World"; -} - -/** - * Return false - * - * @return bool - */ -function Zend_Soap_Client_TestFunc3() -{ - return false; -} - -/** - * Return true - * - * @return bool - */ -function Zend_Soap_Client_TestFunc4() -{ - return true; -} - -/** - * Return integer - * - * @return int - */ -function Zend_Soap_Client_TestFunc5() -{ - return 123; -} - -/** - * Return string - * - * @return string - */ -function Zend_Soap_Client_TestFunc6() -{ - return "string"; -} - -if (PHPUnit_MAIN_METHOD == 'Zend_Soap_ClientTest::main') { - \Zend_Soap_ClientTest::main(); -} diff --git a/test/ServerTest.php b/test/ServerTest.php index 82333218..32a61bc3 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -24,13 +24,10 @@ * @namespace */ namespace ZendTest\Soap; -use Zend\Soap\Server; - -/** PHPUnit Test Case */ - -/** Zend_Soap_Server */ +require_once __DIR__ . '/TestAsset/commontypes.php'; +use Zend\Soap\Server; /** * Zend_Soap_Server @@ -61,8 +58,8 @@ public function testSetOptions() $options = array('soap_version' => SOAP_1_1, 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2',), + 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' ); @@ -77,8 +74,8 @@ public function testSetOptionsViaSecondConstructorArgument() 'soap_version' => SOAP_1_1, 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'classmap' => array( - 'TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2', + 'TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2', ), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -208,8 +205,8 @@ public function testSetClassmap() { $server = new Server\Server(); - $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2'); + $classmap = array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2'); $this->assertNull($server->getClassmap()); $server->setClassmap($classmap); @@ -232,8 +229,8 @@ public function testGetClassmap() { $server = new Server\Server(); - $classmap = array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2'); + $classmap = array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2'); $this->assertNull($server->getClassmap()); $server->setClassmap($classmap); @@ -269,16 +266,16 @@ public function testAddFunction() $server = new Server\Server(); // Correct function should pass - $server->addFunction('Zend_Soap_Server_TestFunc1'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); // Array of correct functions should pass - $functions = array('Zend_Soap_Server_TestFunc2', - 'Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc4'); + $functions = array('ZendTest_Soap_TestAsset_TestFunc2', + 'ZendTest_Soap_TestAsset_TestFunc3', + 'ZendTest_Soap_TestAsset_TestFunc4'); $server->addFunction($functions); $this->assertEquals( - array_merge(array('Zend_Soap_Server_TestFunc1'), $functions), + array_merge(array('ZendTest_Soap_TestAsset_TestFunc'), $functions), $server->getFunctions() ); } @@ -311,9 +308,9 @@ public function testAddBogusFunctionsAsArray() $server = new Server\Server(); try { - $functions = array('Zend_Soap_Server_TestFunc5', + $functions = array('ZendTest_Soap_TestAsset_TestFunc5', 'bogus_function', - 'Zend_Soap_Server_TestFunc6'); + 'ZendTest_Soap_TestAsset_TestFunc6'); $server->addFunction($functions); $this->fail('Invalid function within a set of functions should fail'); } catch (Server\Exception $e) { @@ -337,7 +334,7 @@ public function testSetClass() // Correct class name should pass try { - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); } catch(\Exception $e) { $this->fail("Setting a correct class name should not fail setClass()"); } @@ -349,8 +346,8 @@ public function testSetClassTwiceThrowsException() // Correct class name should pass try { - $server->setClass('Zend_Soap_Server_TestClass'); - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $this->fail(); } catch(Server\Exception $e) { $this->assertEquals('A class has already been registered with this soap server instance', $e->getMessage()); @@ -363,7 +360,7 @@ public function testSetClassWithArguments() // Correct class name should pass try { - $server->setClass('Zend_Soap_Server_TestClass', 1, 2, 3, 4); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass', 1, 2, 3, 4); } catch(\Exception $e) { $this->fail("Setting a correct class name should not fail setClass()"); } @@ -416,10 +413,10 @@ public function testSetObject() } // Correct class name should pass - $server->setObject(new \Zend_Soap_Server_TestClass()); + $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); try { - $server->setObject(new \Zend_Soap_Server_TestClass()); + $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); $this->fail('setClass() should pass only once'); } catch (\Exception $e) { // success @@ -430,25 +427,25 @@ public function testGetFunctions() { $server = new Server\Server(); - $server->addFunction('Zend_Soap_Server_TestFunc1'); + $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); - $functions = array('Zend_Soap_Server_TestFunc2', - 'Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc4'); + $functions = array('ZendTest_Soap_TestAsset_TestFunc2', + 'ZendTest_Soap_TestAsset_TestFunc3', + 'ZendTest_Soap_TestAsset_TestFunc4'); $server->addFunction($functions); - $functions = array('Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc5', - 'Zend_Soap_Server_TestFunc6'); + $functions = array('ZendTest_Soap_TestAsset_TestFunc3', + 'ZendTest_Soap_TestAsset_TestFunc5', + 'ZendTest_Soap_TestAsset_TestFunc6'); $server->addFunction($functions); $allAddedFunctions = array( - 'Zend_Soap_Server_TestFunc1', - 'Zend_Soap_Server_TestFunc2', - 'Zend_Soap_Server_TestFunc3', - 'Zend_Soap_Server_TestFunc4', - 'Zend_Soap_Server_TestFunc5', - 'Zend_Soap_Server_TestFunc6' + 'ZendTest_Soap_TestAsset_TestFunc', + 'ZendTest_Soap_TestAsset_TestFunc2', + 'ZendTest_Soap_TestAsset_TestFunc3', + 'ZendTest_Soap_TestAsset_TestFunc4', + 'ZendTest_Soap_TestAsset_TestFunc5', + 'ZendTest_Soap_TestAsset_TestFunc6' ); $this->assertTrue($server->getFunctions() == $allAddedFunctions); } @@ -456,7 +453,7 @@ public function testGetFunctions() public function testGetFunctionsWithClassAttached() { $server = new Server\Server(); - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $this->assertEquals( array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), @@ -467,7 +464,7 @@ public function testGetFunctionsWithClassAttached() public function testGetFunctionsWithObjectAttached() { $server = new Server\Server(); - $server->setObject(new \Zend_Soap_Server_TestClass()); + $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); $this->assertEquals( array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), @@ -525,7 +522,7 @@ public function testGetLastRequest() $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $request = '' . "\n" @@ -581,7 +578,7 @@ public function testGetLastResponse() $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $request = '' . "\n" @@ -620,6 +617,10 @@ public function testGetLastResponse() public function testHandle() { + if (!extension_loaded('soap')) { + $this->markTestSkipped('Soap extension not loaded'); + } + if (headers_sent()) { $this->markTestSkipped('Cannot run testHandle() when headers have already been sent; enable output buffering to run this test'); return; @@ -628,9 +629,9 @@ public function testHandle() $server = new Server\Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); - $localClient = new \Zend_Soap_Server_TestLocalSoapClient($server, + $localClient = new \ZendTest_Soap_TestAsset_TestLocalSoapClient($server, null, array('location'=>'test://', 'uri'=>'http://framework.zend.com')); @@ -672,7 +673,7 @@ public function testHandle() $server1 = new Server\Server(); $server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - $server1->setClass('Zend_Soap_Server_TestClass'); + $server1->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $server1->setReturnResponse(true); $this->assertEquals($expectedResponse, $server1->handle($request)); @@ -825,7 +826,7 @@ public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHan . '' . '' . "\n"; - $server->setClass('Zend_Soap_Server_TestClass'); + $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $response = $server->handle($request); $this->assertContains( @@ -841,8 +842,8 @@ public function testServerAcceptsZendConfigObject() { $options = array('soap_version' => SOAP_1_1, 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'classmap' => array('TestData1' => 'Zend_Soap_Server_TestData1', - 'TestData2' => 'Zend_Soap_Server_TestData2',), + 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', + 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' ); @@ -881,195 +882,3 @@ public function testSetAndGetWSDLCache() $this->assertEquals(100, $options['cache_wsdl']); } } - - -if (extension_loaded('soap')) { - -/** Local SOAP client */ -class TestLocalSoapClient extends \SoapClient -{ - /** - * Server object - * - * @var Zend_Soap_Server - */ - public $server; - - /** - * Local client constructor - * - * @param Zend_Soap_Server $server - * @param string $wsdl - * @param array $options - */ - function __construct(Server\Server $server, $wsdl, $options) - { - $this->server = $server; - parent::__construct($wsdl, $options); - } - - function __doRequest($request, $location, $action, $version, $one_way = 0) - { - ob_start(); - $this->server->handle($request); - $response = ob_get_clean(); - - return $response; - } -} - -} - - -/** Test Class */ -class TestClass { - /** - * Test Function 1 - * - * @return string - */ - function testFunc1() - { - return "Hello World"; - } - - /** - * Test Function 2 - * - * @param string $who Some Arg - * @return string - */ - function testFunc2($who) - { - return "Hello $who!"; - } - - /** - * Test Function 3 - * - * @param string $who Some Arg - * @param int $when Some - * @return string - */ - function testFunc3($who, $when) - { - return "Hello $who, How are you $when"; - } - - /** - * Test Function 4 - * - * @return string - */ - static function testFunc4() - { - return "I'm Static!"; - } - - /** - * Test Function 5 raises a user error - * - * @return void - */ - function testFunc5() - { - trigger_error("Test Message", E_USER_ERROR); - } -} - - -/** Test class 2 */ -class TestData1 { - /** - * Property1 - * - * @var string - */ - public $property1; - - /** - * Property2 - * - * @var float - */ - public $property2; -} - -/** Test class 2 */ -class TestData2 { - /** - * Property1 - * - * @var integer - */ - public $property1; - - /** - * Property1 - * - * @var float - */ - public $property2; -} - - -/* Test Functions */ - -/** - * Test Function - * - * @param string $arg - * @return string - */ -function Zend_Soap_Server_TestFunc1($who) -{ - return "Hello $who"; -} - -/** - * Test Function 2 - */ -function Zend_Soap_Server_TestFunc2() -{ - return "Hello World"; -} - -/** - * Return false - * - * @return bool - */ -function Zend_Soap_Server_TestFunc3() -{ - return false; -} - -/** - * Return true - * - * @return bool - */ -function Zend_Soap_Server_TestFunc4() -{ - return true; -} - -/** - * Return integer - * - * @return int - */ -function Zend_Soap_Server_TestFunc5() -{ - return 123; -} - -/** - * Return string - * - * @return string - */ -function Zend_Soap_Server_TestFunc6() -{ - return "string"; -} diff --git a/test/TestAsset/WSDLTestClass.php b/test/TestAsset/WSDLTestClass.php new file mode 100644 index 00000000..440eb893 --- /dev/null +++ b/test/TestAsset/WSDLTestClass.php @@ -0,0 +1,16 @@ + 'bar', 'baz' => true, 1 => false, 'bat' => 123); } @@ -101,7 +101,7 @@ function TestFunc7() * * @return StdClass */ -function TestFunc8() +function ZendTest_Soap_TestAsset_TestFunc8() { $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false); return $return; @@ -114,7 +114,7 @@ function TestFunc8() * @param string $bar * @return string */ -function TestFunc9($foo, $bar) +function ZendTest_Soap_TestAsset_TestFunc9($foo, $bar) { return "$foo $bar"; } @@ -126,7 +126,7 @@ function TestFunc9($foo, $bar) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class TestFixingMultiplePrototypes +class ZendTest_Soap_TestAsset_TestFixingMultiplePrototypes { /** * Test function @@ -149,7 +149,7 @@ function testFunc($a=100, $b=200, $d=300) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Test { +class ZendTest_Soap_TestAsset_Test { /** * Test Function 1 * @@ -194,7 +194,7 @@ static function testFunc4() } } -class AutoDiscoverTestClass1 +class ZendTest_Soap_TestAsset_AutoDiscoverTestClass1 { /** * @var integer $var @@ -214,11 +214,11 @@ class AutoDiscoverTestClass1 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class AutoDiscoverTestClass2 +class ZendTest_Soap_TestAsset_AutoDiscoverTestClass2 { /** * - * @param \ZendTest\Soap\_files\AutoDiscoverTestClass1 $test + * @param ZendTest_Soap_TestAsset_AutoDiscoverTestClass1 $test * @return boolean */ public function add(AutoDiscoverTestClass1 $test) @@ -227,7 +227,7 @@ public function add(AutoDiscoverTestClass1 $test) } /** - * @return \ZendTest\Soap\_files\AutoDiscoverTestClass1[] + * @return ZendTest_Soap_TestAsset_AutoDiscoverTestClass1[] */ public function fetchAll() { @@ -238,7 +238,7 @@ public function fetchAll() } /** - * @param \ZendTest\Soap\_files\AutoDiscoverTestClass1[] + * @param ZendTest_Soap_TestAsset_AutoDiscoverTestClass1[] */ public function addMultiple($test) { @@ -253,7 +253,7 @@ public function addMultiple($test) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ComplexTypeB +class ZendTest_Soap_TestAsset_ComplexTypeB { /** * @var string @@ -272,10 +272,10 @@ class ComplexTypeB * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ComplexTypeA +class ZendTest_Soap_TestAsset_ComplexTypeA { /** - * @var \ZendTest\Soap\_files\ComplexTypeB[] + * @var ZendTest_Soap_TestAsset_ComplexTypeB[] */ public $baz = array(); } @@ -287,7 +287,7 @@ class ComplexTypeA * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ComplexTest +class ZendTest_Soap_TestAsset_ComplexTest { /** * @var int @@ -302,7 +302,7 @@ class ComplexTest * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ComplexObjectStructure +class ZendTest_Soap_TestAsset_ComplexObjectStructure { /** * @var boolean @@ -332,10 +332,10 @@ class ComplexObjectStructure * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ComplexObjectWithObjectStructure +class ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure { /** - * @var \ZendTest\Soap\_files\ComplexTest + * @var ZendTest_Soap_TestAsset_ComplexTest */ public $object; } @@ -347,24 +347,24 @@ class ComplexObjectWithObjectStructure * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class MyService +class ZendTest_Soap_TestAsset_MyService { /** * @param string $foo - * @return \ZendTest\Soap\_files\MyResponse[] + * @return ZendTest_Soap_TestAsset_MyResponse[] */ public function foo($foo) { } /** * @param string $bar - * @return \ZendTest\Soap\_files\MyResponse[] + * @return ZendTest_Soap_TestAsset_MyResponse[] */ public function bar($bar) { } /** * @param string $baz - * @return \ZendTest\Soap\_files\MyResponse[] + * @return ZendTest_Soap_TestAsset_MyResponse[] */ public function baz($baz) { } @@ -377,7 +377,7 @@ public function baz($baz) { * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class MyServiceSequence +class ZendTest_Soap_TestAsset_MyServiceSequence { /** * @param string $foo @@ -414,7 +414,7 @@ public function bazNested($baz) { * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class MyResponse +class ZendTest_Soap_TestAsset_MyResponse { /** * @var string @@ -429,10 +429,10 @@ class MyResponse * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Recursion +class ZendTest_Soap_TestAsset_Recursion { /** - * @var \ZendTest\Soap\_files\Recursion + * @var ZendTest_Soap_TestAsset_Recursion */ public $recursion; } @@ -440,7 +440,7 @@ class Recursion /** * @param string $message */ -function OneWay($message) +function ZendTest_Soap_TestAsset_OneWay($message) { } @@ -452,7 +452,7 @@ function OneWay($message) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class NoReturnType +class ZendTest_Soap_TestAsset_NoReturnType { /** * @@ -463,3 +463,178 @@ public function pushOneWay($message) } } + +/* Client test classes */ +/** Test Class */ +class ZendTest_Soap_TestAsset_TestClass { + /** + * Test Function 1 + * + * @return string + */ + function testFunc1() + { + return "Hello World"; + } + + /** + * Test Function 2 + * + * @param string $who Some Arg + * @return string + */ + function testFunc2($who) + { + return "Hello $who!"; + } + + /** + * Test Function 3 + * + * @param string $who Some Arg + * @param int $when Some + * @return string + */ + function testFunc3($who, $when) + { + return "Hello $who, How are you $when"; + } + + /** + * Test Function 4 + * + * @return string + */ + static function testFunc4() + { + return "I'm Static!"; + } +} + +/** Test class 2 */ +class ZendTest_Soap_TestAsset_TestData1 { + /** + * Property1 + * + * @var string + */ + public $property1; + + /** + * Property2 + * + * @var float + */ + public $property2; +} + +/** Test class 2 */ +class ZendTest_Soap_TestAsset_TestData2 { + /** + * Property1 + * + * @var integer + */ + public $property1; + + /** + * Property1 + * + * @var float + */ + public $property2; +} + +/** Server test classes */ +class ZendTest_Soap_TestAsset_ServerTestClass +{ + /** + * Test Function 1 + * + * @return string + */ + function testFunc1() + { + return "Hello World"; + } + + /** + * Test Function 2 + * + * @param string $who Some Arg + * @return string + */ + function testFunc2($who) + { + return "Hello $who!"; + } + + /** + * Test Function 3 + * + * @param string $who Some Arg + * @param int $when Some + * @return string + */ + function testFunc3($who, $when) + { + return "Hello $who, How are you $when"; + } + + /** + * Test Function 4 + * + * @return string + */ + static function testFunc4() + { + return "I'm Static!"; + } + + /** + * Test Function 5 raises a user error + * + * @return void + */ + function testFunc5() + { + trigger_error("Test Message", E_USER_ERROR); + } +} + +if (extension_loaded('soap')) { + +/** Local SOAP client */ +class ZendTest_Soap_TestAsset_TestLocalSoapClient extends \SoapClient +{ + /** + * Server object + * + * @var Zend_Soap_Server + */ + public $server; + + /** + * Local client constructor + * + * @param Zend_Soap_Server $server + * @param string $wsdl + * @param array $options + */ + function __construct(\Zend\Soap\Server\Server $server, $wsdl, $options) + { + $this->server = $server; + parent::__construct($wsdl, $options); + } + + function __doRequest($request, $location, $action, $version, $one_way = 0) + { + ob_start(); + $this->server->handle($request); + $response = ob_get_clean(); + + return $response; + } +} + +} diff --git a/test/_files/fulltests/server1.php b/test/TestAsset/fulltests/server1.php similarity index 100% rename from test/_files/fulltests/server1.php rename to test/TestAsset/fulltests/server1.php diff --git a/test/_files/fulltests/server2.php b/test/TestAsset/fulltests/server2.php similarity index 100% rename from test/_files/fulltests/server2.php rename to test/TestAsset/fulltests/server2.php diff --git a/test/_files/wsdl_documentation.wsdl b/test/TestAsset/wsdl_documentation.wsdl similarity index 100% rename from test/_files/wsdl_documentation.wsdl rename to test/TestAsset/wsdl_documentation.wsdl diff --git a/test/TestAsset/wsdl_example.wsdl b/test/TestAsset/wsdl_example.wsdl new file mode 100644 index 00000000..907a837c --- /dev/null +++ b/test/TestAsset/wsdl_example.wsdl @@ -0,0 +1,2 @@ + + diff --git a/test/WSDL/ArrayOfTypeComplexStrategyTest.php b/test/WSDL/ArrayOfTypeComplexStrategyTest.php index 167b925a..b310bc98 100644 --- a/test/WSDL/ArrayOfTypeComplexStrategyTest.php +++ b/test/WSDL/ArrayOfTypeComplexStrategyTest.php @@ -24,9 +24,11 @@ * @namespace */ namespace ZendTest\Soap\WSDL; + +require_once __DIR__."/../TestAsset/commontypes.php"; + use Zend\Soap\WSDL; -require_once dirname(__FILE__)."/../_files/commontypes.php"; /** * @category Zend @@ -50,21 +52,14 @@ public function setUp() public function testNestingObjectsDeepMakesNoSenseThrowingException() { - try { - $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexTest[][]'); - $this->fail(); - } catch(WSDL\Exception $e) { - - } + $this->setExpectedException('Zend\Soap\WSDL\Exception'); + $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[][]'); } public function testAddComplexTypeOfNonExistingClassThrowsException() { - try { - $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\UnknownClass[]'); - } catch(WSDL\Exception $e) { - - } + $this->setExpectedException('Zend\Soap\WSDL\Exception'); + $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_UnknownClass[]'); } /** @@ -72,27 +67,28 @@ public function testAddComplexTypeOfNonExistingClassThrowsException() */ public function testArrayOfSimpleObject() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexTest[]'); - $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexTest", $return); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[]'); + $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexTest", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', + $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } public function testThatOverridingStrategyIsReset() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexTest[]'); - $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexTest", $return); - #$this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplexStrategy); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[]'); + $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexTest", $return); + // $this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplexStrategy); $wsdl = $this->wsdl->toXML(); } @@ -102,41 +98,43 @@ public function testThatOverridingStrategyIsReset() */ public function testArrayOfComplexObjects() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectStructure[]'); - $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexObjectStructure", $return); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectStructure[]'); + $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexObjectStructure", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', + $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } public function testArrayOfObjectWithObject() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); - $this->assertEquals("tns:ArrayOf\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure", $return); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); + $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); $this->assertContains( - '', + '', + $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } @@ -146,19 +144,19 @@ public function testArrayOfObjectWithObject() */ public function testAddingTypesMultipleTimesIsSavedOnlyOnce() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); $wsdl = $this->wsdl->toXML(); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]"') + substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]"') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); } @@ -167,19 +165,19 @@ public function testAddingTypesMultipleTimesIsSavedOnlyOnce() */ public function testAddingSingularThenArrayTypeIsRecognizedCorretly() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure'); - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure'); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); $wsdl = $this->wsdl->toXML(); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:\ZendTest\Soap\WSDL\ComplexObjectWithObjectStructure[]"') + substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]"') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); } @@ -189,7 +187,7 @@ public function testAddingSingularThenArrayTypeIsRecognizedCorretly() public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowingException() { try { - $return = $this->wsdl->addComplexType("\ZendTest\Soap\WSDL\ComplexTypeA"); + $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_ComplexTypeA"); $wsdl = $this->wsdl->toXml(); } catch(\Exception $e) { $this->fail("Adding object with nested structure should not throw exception."); @@ -201,19 +199,19 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowing */ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllTypesRecursivly() { - $return = $this->wsdl->addComplexType("\ZendTest\Soap\WSDL\ComplexTypeA"); + $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_ComplexTypeA"); $wsdl = $this->wsdl->toXml(); $this->assertEquals(1, - substr_count($wsdl, ''), + substr_count($wsdl, ''), 'No definition of complex type A found.' ); $this->assertEquals(1, - substr_count($wsdl, ''), + substr_count($wsdl, ''), 'No definition of complex type B array found.' ); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:\ZendTest\Soap\WSDL\ComplexTypeB[]"'), + substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_ComplexTypeB[]"'), 'No usage of Complex Type B array found.' ); } @@ -223,11 +221,7 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllType */ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() { - try { - $return = $this->wsdl->addComplexType("Zend_Soap_AutoDiscover_Recursion"); - } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Exception); - $this->assertEquals('Infinite recursion, cannot nest \'\ZendTest\Soap\_files\Recursion\' into itself.', $e->getMessage()); - } + $this->setExpectedException('Zend\Soap\WSDL\Exception', 'Infinite recursion'); + $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_Recursion"); } } diff --git a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php index 22bec921..79339f48 100644 --- a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php +++ b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php @@ -24,6 +24,8 @@ */ namespace ZendTest\Soap\WSDL; +require_once __DIR__ . '/../TestAsset/commontypes.php'; + /** * @category Zend * @package Zend_Soap @@ -129,19 +131,20 @@ public function testAddComplexTypeObject() public function testAddComplexTypeArrayOfObject() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\SequenceTest[]'); + $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTypeA[]'); - $this->assertEquals('tns:ArrayOf\ZendTest\Soap\WSDL\Sequencetest', $return); + $this->assertEquals('tns:ArrayOfZendtest_soap_testasset_complextypea', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', + $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } diff --git a/test/WSDL/DefaultComplexTypeTest.php b/test/WSDL/DefaultComplexTypeTest.php index 551d2d1d..45d8e4d9 100644 --- a/test/WSDL/DefaultComplexTypeTest.php +++ b/test/WSDL/DefaultComplexTypeTest.php @@ -59,7 +59,7 @@ public function setUp() */ public function testOnlyPublicPropertiesAreDiscoveredByStrategy() { - $this->strategy->addComplexType('\ZendTest\Soap\WSDL\DefaultComplexTypeTest\PublicPrivateProtected'); + $this->strategy->addComplexType('\ZendTest\Soap\WSDL\PublicPrivateProtected'); $xml = $this->wsdl->toXML(); $this->assertNotContains( PublicPrivateProtected::PROTECTED_VAR_NAME, $xml); diff --git a/test/WSDL/ElementTest.php b/test/WSDL/ElementTest.php index dc82fa35..e1dd96f0 100644 --- a/test/WSDL/ElementTest.php +++ b/test/WSDL/ElementTest.php @@ -38,7 +38,6 @@ */ class ElementTest extends \PHPUnit_Framework_TestCase { -/* public function testBindingElementApi() { $operations = new WSDL\Element\Collection("test"); @@ -242,5 +241,4 @@ public function testCollectionElementApiElementAccess() $this->assertTrue( in_array($name, $collection->getElementNames()) ); } } -*/ } diff --git a/test/WSDL/ParserTest.php b/test/WSDL/ParserTest.php index a566a7b7..04d94e10 100644 --- a/test/WSDL/ParserTest.php +++ b/test/WSDL/ParserTest.php @@ -41,11 +41,10 @@ class ParserTest extends \PHPUnit_Framework_TestCase protected function getWSDLExampleDom() { $dom = new \DOMDocument(); - $dom->loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl")); + $dom->loadXml(file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl")); return $dom; } -/* public function testFactoryWithDomDocument() { $dom = $this->getWSDLExampleDom(); @@ -55,14 +54,14 @@ public function testFactoryWithDomDocument() public function testFactoryWithString() { - $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); + $xmlString = file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl"); $parser = WSDL\Parser::factory($xmlString); $this->assertTrue($parser instanceof WSDL\Parser); } public function testFactoryWithSimpleXml() { - $xmlString = file_get_contents(dirname(__FILE__)."/../_files/wsdl_example.wsdl"); + $xmlString = file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl"); $simpleXml = simplexml_load_string($xmlString); $parser = WSDL\Parser::factory($simpleXml); $this->assertTrue($parser instanceof WSDL\Parser); @@ -183,10 +182,9 @@ public function testParseExampleWSDLAndCheckMatchingNames() public function testParseExampleWSDLWithDocumentationBlocks() { $dom = new \DOMDocument(); - $dom->loadXml(file_get_contents(dirname(__FILE__)."/../_files/wsdl_documentation.wsdl")); + $dom->loadXml(file_get_contents(__DIR__."/../TestAsset/wsdl_documentation.wsdl")); $parser = new WSDL\Parser($dom); $result = $parser->parse(); } -*/ } diff --git a/test/WSDLTest.php b/test/WSDLTest.php index 68ef8d44..668a888c 100644 --- a/test/WSDLTest.php +++ b/test/WSDLTest.php @@ -497,8 +497,8 @@ function testDump() . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' ); - $wsdl->dump(dirname(__FILE__) . '/_files/dumped.wsdl'); - $dumpedContent = file_get_contents(dirname(__FILE__) . '/_files/dumped.wsdl'); + $wsdl->dump(__DIR__ . '/TestAsset/dumped.wsdl'); + $dumpedContent = file_get_contents(__DIR__ . '/TestAsset/dumped.wsdl'); $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($dumpedContent), '' . @@ -510,7 +510,7 @@ function testDump() . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>' ); - unlink(dirname(__FILE__) . '/_files/dumped.wsdl'); + unlink(__DIR__ . '/TestAsset/dumped.wsdl'); } function testGetType() @@ -534,22 +534,22 @@ function testGetType() function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() { $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', true); - $this->assertEquals('tns:Zend_Soap_WSDL_Test', $wsdl->getType('Zend_Soap_WSDL_Test')); + $this->assertEquals('tns:ZendTest_Soap_TestAsset_WSDLTestClass', $wsdl->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', false); - $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_WSDL_Test')); + $this->assertEquals('xsd:anyType', $wsdl2->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } function testGetComplexTypeBasedOnStrategiesStringNames() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_DefaultComplexType'); - $this->assertEquals('tns:Zend_Soap_WSDL_Test', $wsdl->getType('Zend_Soap_WSDL_Test')); + $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\DefaultComplexType'); + $this->assertEquals('tns:ZendTest_Soap_TestAsset_WSDLTestClass', $wsdl->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_AnyType'); - $this->assertEquals('xsd:anyType', $wsdl2->getType('Zend_Soap_WSDL_Test')); + $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\AnyType'); + $this->assertEquals('xsd:anyType', $wsdl2->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } @@ -571,7 +571,7 @@ function testSettingUnknownStrategyThrowsException() function testSettingInvalidStrategyObjectThrowsException() { try { - $strategy = new \Zend_Soap_WSDL_Test(); + $strategy = new \ZendTest_Soap_TestAsset_WSDLTestClass(); $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', $strategy); $this->fail(); } catch(WSDL\Exception $e) { @@ -583,11 +583,11 @@ function testAddingSameComplexTypeMoreThanOnceIsIgnored() { try { $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addType('Zend_Soap_WSDL_Test'); - $wsdl->addType('Zend_Soap_WSDL_Test'); + $wsdl->addType('ZendTest_Soap_TestAsset_WSDLTestClass'); + $wsdl->addType('ZendTest_Soap_TestAsset_WSDLTestClass'); $types = $wsdl->getTypes(); $this->assertEquals(1, count($types)); - $this->assertEquals(array("Zend_Soap_WSDL_Test"), $types); + $this->assertEquals(array("ZendTest_Soap_TestAsset_WSDLTestClass"), $types); } catch(WSDL\Exception $e) { $this->fail(); } @@ -596,18 +596,18 @@ function testAddingSameComplexTypeMoreThanOnceIsIgnored() function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() { $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('Zend_Soap_WSDL_Test'); - $this->assertEquals(array('Zend_Soap_WSDL_Test'), $wsdl->getTypes()); + $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); + $this->assertEquals(array('ZendTest_Soap_TestAsset_WSDLTestClass'), $wsdl->getTypes()); - $wsdl->addComplexType('Zend_Soap_WSDL_Test'); - $this->assertEquals(array('Zend_Soap_WSDL_Test'), $wsdl->getTypes()); + $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); + $this->assertEquals(array('ZendTest_Soap_TestAsset_WSDLTestClass'), $wsdl->getTypes()); } function testAddComplexType() { $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('Zend_Soap_WSDL_Test'); + $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . @@ -620,7 +620,7 @@ function testAddComplexType() . 'name="MyService" targetNamespace="http://localhost/MyService.php">' . '' . '' - . '' + . '' . '' . '' . '' @@ -685,20 +685,3 @@ public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly() $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } } - - - -/** - * Test Class - */ -class Test { - /** - * @var integer - */ - public $var1; - - /** - * @var string - */ - public $var2; -} diff --git a/test/_files/wsdl_example.wsdl b/test/_files/wsdl_example.wsdl deleted file mode 100644 index 4eaa8761..00000000 --- a/test/_files/wsdl_example.wsdl +++ /dev/null @@ -1,2 +0,0 @@ - - From 84db52d90469b69d45a1b807f88735a98d376c71 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 6 Jul 2010 08:57:12 -0400 Subject: [PATCH 046/123] Zend\Soap cleanup - Moved all orphaned subcomponents (those with just a class and exception) up one level - Moved Client\Client to Client and Client\Exception to ClientException - Moved WSDL\WSDL to WSDL - Moved WSDL\Strategy\StrategyInterface to WSDL\Strategy - Updated all code and tests to reflect the above --- src/{AutoDiscover => }/AutoDiscover.php | 65 +++++----- src/AutoDiscoverException.php | 35 ++++++ src/{Client => }/Client.php | 40 +++--- src/Client/DotNet.php | 15 ++- src/Client/Local.php | 15 ++- .../Exception.php => ClientException.php} | 6 +- src/{AutoDiscover => }/Exception.php | 2 +- src/{Server => }/Server.php | 96 +++++++------- .../Exception.php => ServerException.php} | 6 +- src/{WSDL => }/WSDL.php | 35 +++--- .../StrategyInterface.php => Strategy.php} | 6 +- src/WSDL/Strategy/AbstractStrategy.php | 12 +- src/WSDL/Strategy/AnyType.php | 8 +- src/WSDL/Strategy/ArrayOfTypeComplex.php | 9 +- src/WSDL/Strategy/ArrayOfTypeSequence.php | 2 +- src/WSDL/Strategy/Composite.php | 47 +++---- src/WSDL/Strategy/DefaultComplexType.php | 6 +- src/{WSDL/Exception.php => WSDLException.php} | 6 +- test/AutoDiscover/OnlineTest.php | 4 +- test/AutoDiscoverTest.php | 4 +- test/ClientTest.php | 26 ++-- test/ServerTest.php | 119 +++++++++--------- test/TestAsset/commontypes.php | 2 +- test/TestAsset/fulltests/server1.php | 14 +-- test/TestAsset/fulltests/server2.php | 10 +- test/WSDL/ArrayOfTypeComplexStrategyTest.php | 8 +- test/WSDL/ArrayOfTypeSequenceStrategyTest.php | 7 +- test/WSDL/CompositeStrategyTest.php | 15 +-- test/WSDL/DefaultComplexTypeTest.php | 2 +- test/WSDL/ElementTest.php | 25 ++-- test/WSDL/ParserTest.php | 9 +- test/WSDLTest.php | 71 +++++------ 32 files changed, 393 insertions(+), 334 deletions(-) rename src/{AutoDiscover => }/AutoDiscover.php (89%) create mode 100644 src/AutoDiscoverException.php rename src/{Client => }/Client.php (94%) rename src/{Client/Exception.php => ClientException.php} (90%) rename src/{AutoDiscover => }/Exception.php (96%) rename src/{Server => }/Server.php (89%) rename src/{Server/Exception.php => ServerException.php} (90%) rename src/{WSDL => }/WSDL.php (95%) rename src/WSDL/{Strategy/StrategyInterface.php => Strategy.php} (91%) rename src/{WSDL/Exception.php => WSDLException.php} (90%) diff --git a/src/AutoDiscover/AutoDiscover.php b/src/AutoDiscover.php similarity index 89% rename from src/AutoDiscover/AutoDiscover.php rename to src/AutoDiscover.php index 9fae7e8d..8f87ce06 100644 --- a/src/AutoDiscover/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -23,18 +23,19 @@ /** * @namespace */ -namespace Zend\Soap\AutoDiscover; -use Zend\URI; -use Zend\Soap\WSDL; +namespace Zend\Soap; + +use Zend\URI, + Zend\Soap\WSDL; /** - * \Zend\Soap\AutoDiscover\AutoDiscover + * \Zend\Soap\AutoDiscover * * @uses \Zend\Server\AbstractServer * @uses \Zend\Server\Server * @uses \Zend\Server\Reflection\Reflection * @uses \Zend\Soap\AutoDiscover\Exception - * @uses \Zend\Soap\WSDL\WSDL + * @uses \Zend\Soap\WSDL * @uses \Zend\URI\URI * @category Zend * @package Zend_Soap @@ -43,7 +44,7 @@ class AutoDiscover implements \Zend\Server\Server { /** - * @var \Zend\Soap\WSDL\WSDL + * @var \Zend\Soap\WSDL */ protected $_wsdl = null; @@ -88,12 +89,12 @@ class AutoDiscover implements \Zend\Server\Server * * @var string */ - protected $_wsdlClass = '\Zend\Soap\WSDL\WSDL'; + protected $_wsdlClass = '\Zend\Soap\WSDL'; /** * Constructor * - * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy * @param string|\Zend\URI\URI $uri * @param string $wsdlClass */ @@ -116,19 +117,19 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null) * * @throws \Zend\Soap\AutoDiscover\Exception * @param \Zend\URI\URI|string $uri - * @return \Zend\Soap\AutoDiscover\AutoDiscover + * @return \Zend\Soap\AutoDiscover */ public function setUri($uri) { if(!is_string($uri) && !($uri instanceof URI\URI)) { - throw new Exception( - 'No uri given to \Zend\Soap\AutoDiscover\AutoDiscover::setUri as string or \Zend\URI\URI instance.' + throw new AutoDiscoverException( + 'No uri given to \Zend\Soap\AutoDiscover::setUri as string or \Zend\URI\URI instance.' ); } $this->_uri = $uri; // change uri in WSDL file also if existant - if($this->_wsdl instanceof WSDL\WSDL) { + if($this->_wsdl instanceof WSDL) { $this->_wsdl->setUri($uri); } @@ -159,13 +160,13 @@ public function getUri() * * @throws \Zend\Soap\AutoDiscover\Exception * @param string $wsdlClass - * @return \Zend\Soap\AutoDiscover\AutoDiscover + * @return \Zend\Soap\AutoDiscover */ public function setWSDLClass($wsdlClass) { - if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, '\Zend\Soap\WSDL\WSDL')) { - throw new Exception( - 'No \Zend\Soap\WSDL\WSDL subclass given to \Zend\Soap\AutoDiscover\AutoDiscover::setWSDLClass as string.' + if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\WSDL')) { + throw new AutoDiscoverException( + 'No \Zend\Soap\WSDL subclass given to Zend\Soap\AutoDiscover::setWSDLClass as string.' ); } $this->_wsdlClass = $wsdlClass; @@ -190,12 +191,12 @@ public function getWSDLClass() * 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/". * * @param array $operationStyle - * @return \Zend\Soap\AutoDiscover\AutoDiscover + * @return \Zend\Soap\AutoDiscover */ public function setOperationBodyStyle(array $operationStyle=array()) { if(!isset($operationStyle['use'])) { - throw new Exception("Key 'use' is required in Operation soap:body style."); + throw new AutoDiscoverException("Key 'use' is required in Operation soap:body style."); } $this->_operationBodyStyle = $operationStyle; return $this; @@ -207,7 +208,7 @@ public function setOperationBodyStyle(array $operationStyle=array()) * By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'. * * @param array $bindingStyle - * @return \Zend\Soap\AutoDiscover\AutoDiscover + * @return \Zend\Soap\AutoDiscover */ public function setBindingStyle(array $bindingStyle=array()) { @@ -275,13 +276,13 @@ protected function getRequestUriWithoutParameters() /** * Set the strategy that handles functions and classes that are added AFTER this call. * - * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy - * @return \Zend\Soap\AutoDiscover\AutoDiscover + * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy + * @return \Zend\Soap\AutoDiscover */ public function setComplexTypeStrategy($strategy) { $this->_strategy = $strategy; - if($this->_wsdl instanceof WSDL\WSDL) { + if($this->_wsdl instanceof WSDL) { $this->_wsdl->setComplexTypeStrategy($strategy); } @@ -333,10 +334,10 @@ public function addFunction($function, $namespace = '') $uri = $this->getUri(); - if (!($this->_wsdl instanceof WSDL\WSDL)) { + if (!($this->_wsdl instanceof WSDL)) { $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; - $wsdl = new WSDL\WSDL($name, $uri, $this->_strategy); + $wsdl = new WSDL($name, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); @@ -361,7 +362,7 @@ public function addFunction($function, $namespace = '') * Add a function to the WSDL document. * * @param $function \Zend\Server\Reflection\AbstractFunction function to add - * @param $wsdl \Zend\Soap\WSDL\WSDL WSDL document + * @param $wsdl \Zend\Soap\WSDL WSDL document * @param $port object wsdl:portType * @param $binding object wsdl:binding * @return void @@ -381,7 +382,7 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) } } if ($prototype === null) { - throw new Exception("No prototypes could be found for the '" . $function->getName() . "' function"); + throw new AutoDiscoverException("No prototypes could be found for the '" . $function->getName() . "' function"); } // Add the input message (parameters) @@ -475,7 +476,7 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) */ public function fault($fault = null, $code = null) { - throw new Exception('Function has no use in AutoDiscover.'); + throw new AutoDiscoverException('Function has no use in AutoDiscover.'); } /** @@ -501,7 +502,7 @@ public function dump($filename) if($this->_wsdl !== null) { return $this->_wsdl->dump($filename); } else { - throw new Exception('Cannot dump autodiscovered contents, WSDL file has not been generated yet.'); + throw new AutoDiscoverException('Cannot dump autodiscovered contents, WSDL file has not been generated yet.'); } } @@ -513,7 +514,7 @@ public function toXml() if($this->_wsdl !== null) { return $this->_wsdl->toXml(); } else { - throw new Exception('Cannot return autodiscovered contents, WSDL file has not been generated yet.'); + throw new AutoDiscoverException('Cannot return autodiscovered contents, WSDL file has not been generated yet.'); } } @@ -534,7 +535,7 @@ public function getFunctions() */ public function loadFunctions($definition) { - throw new Exception('Function has no use in AutoDiscover.'); + throw new AutoDiscoverException('Function has no use in AutoDiscover.'); } /** @@ -544,7 +545,7 @@ public function loadFunctions($definition) */ public function setPersistence($mode) { - throw new Exception('Function has no use in AutoDiscover.'); + throw new AutoDiscoverException('Function has no use in AutoDiscover.'); } /** @@ -555,7 +556,7 @@ public function setPersistence($mode) */ public function getType($type) { - if (!($this->_wsdl instanceof WSDL\WSDL)) { + if (!($this->_wsdl instanceof WSDL)) { /** @todo Exception throwing may be more correct */ // WSDL is not defined yet, so we can't recognize type in context of current service diff --git a/src/AutoDiscoverException.php b/src/AutoDiscoverException.php new file mode 100644 index 00000000..1eeb0e2f --- /dev/null +++ b/src/AutoDiscoverException.php @@ -0,0 +1,35 @@ +_soapVersion = $version; @@ -368,7 +368,7 @@ public function setClassmap(array $classmap) { foreach ($classmap as $type => $class) { if (!class_exists($class)) { - throw new Exception('Invalid class in class map'); + throw new ClientException('Invalid class in class map'); } } @@ -399,7 +399,7 @@ public function getClassmap() public function setEncoding($encoding) { if (!is_string($encoding)) { - throw new Exception('Invalid encoding specified'); + throw new ClientException('Invalid encoding specified'); } $this->_encoding = $encoding; @@ -430,7 +430,7 @@ public function validateUrn($urn) { $scheme = parse_url($urn, PHP_URL_SCHEME); if ($scheme === false || $scheme === null) { - throw new Exception('Invalid URN'); + throw new ClientException('Invalid URN'); } return true; @@ -505,7 +505,7 @@ public function getLocation() public function setStyle($style) { if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) { - throw new Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); + throw new ClientException('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.'); } $this->_style = $style; @@ -535,7 +535,7 @@ public function getStyle() public function setEncodingMethod($use) { if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) { - throw new Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); + throw new ClientException('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.'); } $this->_use = $use; @@ -705,7 +705,7 @@ public function setProxyPassword($proxyPassword) public function setHttpsCertificate($localCert) { if (!is_readable($localCert)) { - throw new Exception('Invalid HTTPS client certificate path.'); + throw new ClientException('Invalid HTTPS client certificate path.'); } $this->_local_cert = $localCert; @@ -793,7 +793,7 @@ public function getProxyPassword() public function setStreamContext($context) { if(!is_resource($context) || get_resource_type($context) !== "stream-context") { - throw new Exception('Invalid stream context resource given.'); + throw new ClientException('Invalid stream context resource given.'); } $this->_stream_context = $context; @@ -960,7 +960,7 @@ public function getLastMethod() * @param int $one_way * @return mixed */ - public function _doRequest(Common $client, $request, $location, $action, $version, $one_way = null) + public function _doRequest(Client\Common $client, $request, $location, $action, $version, $one_way = null) { // Perform request as is if ($one_way == null) { @@ -982,22 +982,22 @@ protected function _initSoapClientObject() if ($wsdl == null) { if (!isset($options['location'])) { - throw new Exception('\'location\' parameter is required in non-WSDL mode.'); + throw new ClientException('\'location\' parameter is required in non-WSDL mode.'); } if (!isset($options['uri'])) { - throw new Exception('\'uri\' parameter is required in non-WSDL mode.'); + throw new ClientException('\'uri\' parameter is required in non-WSDL mode.'); } } else { if (isset($options['use'])) { - throw new Exception('\'use\' parameter only works in non-WSDL mode.'); + throw new ClientException('\'use\' parameter only works in non-WSDL mode.'); } if (isset($options['style'])) { - throw new Exception('\'style\' parameter only works in non-WSDL mode.'); + throw new ClientException('\'style\' parameter only works in non-WSDL mode.'); } } unset($options['wsdl']); - $this->_soapClient = new Common(array($this, '_doRequest'), $wsdl, $options); + $this->_soapClient = new Client\Common(array($this, '_doRequest'), $wsdl, $options); } @@ -1104,7 +1104,7 @@ public function __call($name, $arguments) public function getFunctions() { if ($this->getWSDL() == null) { - throw new Exception('\'getFunctions\' method is available only in WSDL mode.'); + throw new ClientException('\'getFunctions\' method is available only in WSDL mode.'); } $soapClient = $this->getSoapClient(); @@ -1127,7 +1127,7 @@ public function getFunctions() public function getTypes() { if ($this->getWSDL() == null) { - throw new Exception('\'getTypes\' method is available only in WSDL mode.'); + throw new ClientException('\'getTypes\' method is available only in WSDL mode.'); } $soapClient = $this->getSoapClient(); diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 079723ff..3704e2ac 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -25,8 +25,11 @@ */ namespace Zend\Soap\Client; +use Zend\Soap\Client as SOAPClient, + Zend\Soap\ClientException; + /** - * Zend_Soap_Client_Local + * .NET SOAP client * * Class is intended to be used with .Net Web Services. * @@ -34,13 +37,13 @@ * Please leave your notes, compatiblity issues reports or * suggestions in fw-webservices@lists.zend.com or fw-general@lists.com * - * @uses \Zend\Soap\Client\Client - * @uses \Zend\Soap\Client\Exception + * @uses \Zend\Soap\Client + * @uses \Zend\Soap\ClientException * @category Zend * @package Zend_Soap * @subpackage Client */ -class DotNet extends Client +class DotNet extends SOAPClient { /** * Constructor @@ -63,14 +66,14 @@ public function __construct($wsdl = null, $options = null) * My be overridden in descendant classes * * @param array $arguments - * @throws \Zend\Soap\Client\Exception + * @throws \Zend\Soap\ClientException */ protected function _preProcessArguments($arguments) { if (count($arguments) > 1 || (count($arguments) == 1 && !is_array(reset($arguments))) ) { - throw new Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); + throw new ClientException('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).'); } // Do nothing diff --git a/src/Client/Local.php b/src/Client/Local.php index cb62a8c4..997a91b5 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -25,6 +25,9 @@ */ namespace Zend\Soap\Client; +use Zend\Soap\Client as SOAPClient, + Zend\Soap\Server as SOAPServer; + /** * \Zend\Soap\Client\Local * @@ -33,29 +36,29 @@ * * Could be used for development or testing purposes. * - * @uses \Zend\Soap\Client\Client - * @uses \Zend\Soap\Server\Server + * @uses \Zend\Soap\Client + * @uses \Zend\Soap\Server * @category Zend * @package Zend_Soap * @subpackage Client */ -class Local extends Client +class Local extends SOAPClient { /** * Server object * - * @var \Zend\Soap\Server\Server + * @var \Zend\Soap\Server */ protected $_server; /** * Local client constructor * - * @param \Zend\Soap\Server\Server $server + * @param \Zend\Soap\Server $server * @param string $wsdl * @param array $options */ - function __construct(\Zend\Soap\Server\Server $server, $wsdl, $options = null) + function __construct(SOAPServer $server, $wsdl, $options = null) { $this->_server = $server; diff --git a/src/Client/Exception.php b/src/ClientException.php similarity index 90% rename from src/Client/Exception.php rename to src/ClientException.php index da720b12..4544343d 100644 --- a/src/Client/Exception.php +++ b/src/ClientException.php @@ -22,10 +22,10 @@ /** * @namespace */ -namespace Zend\Soap\Client; +namespace Zend\Soap; /** - * @uses \Zend\Exception + * @uses \Zend\Soap\Exception * @category Zend * @package Zend_Soap * @subpackage Client @@ -33,6 +33,6 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -class Exception extends \Zend\Exception +class ClientException extends Exception {} diff --git a/src/AutoDiscover/Exception.php b/src/Exception.php similarity index 96% rename from src/AutoDiscover/Exception.php rename to src/Exception.php index 5c752fff..957d1518 100644 --- a/src/AutoDiscover/Exception.php +++ b/src/Exception.php @@ -23,7 +23,7 @@ /** * @namespace */ -namespace Zend\Soap\AutoDiscover; +namespace Zend\Soap; /** * @uses \Zend\Exception diff --git a/src/Server/Server.php b/src/Server.php similarity index 89% rename from src/Server/Server.php rename to src/Server.php index b5ad707c..8d8cc6da 100644 --- a/src/Server/Server.php +++ b/src/Server.php @@ -22,7 +22,9 @@ /** * @namespace */ -namespace Zend\Soap\Server; +namespace Zend\Soap; + +use Zend\Config\Config; /** * Zend_Soap_Server @@ -30,8 +32,8 @@ * @uses DOMDocument * @uses SoapFault * @uses SoapServer - * @uses \Zend\Server\Server - * @uses \Zend\Soap\Server\Exception + * @uses \Zend\Server + * @uses \Zend\Soap\ServerException * @category Zend * @package Zend_Soap * @subpackage Server @@ -160,12 +162,12 @@ class Server implements \Zend\Server\Server * @param string $wsdl * @param array $options * @return void - * @throws \Zend\Soap\Server\Exception + * @throws \Zend\Soap\ServerException */ public function __construct($wsdl = null, array $options = null) { if (!extension_loaded('soap')) { - throw new Exception('SOAP extension is not loaded.'); + throw new ServerException('SOAP extension is not loaded.'); } if (null !== $wsdl) { @@ -183,11 +185,11 @@ public function __construct($wsdl = null, array $options = null) * Allows setting options as an associative array of option => value pairs. * * @param array|\Zend\Config\Config $options - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setOptions($options) { - if($options instanceof \Zend\Config\Config) { + if($options instanceof Config) { $options = $options->toArray(); } @@ -270,13 +272,13 @@ public function getOptions() * Set encoding * * @param string $encoding - * @return \Zend\Soap\Server\Server - * @throws \Zend\Soap\Server\Exception with invalid encoding argument + * @return \Zend\Soap\Server + * @throws \Zend\Soap\ServerException with invalid encoding argument */ public function setEncoding($encoding) { if (!is_string($encoding)) { - throw new Exception('Invalid encoding specified'); + throw new ServerException('Invalid encoding specified'); } $this->_encoding = $encoding; @@ -297,13 +299,13 @@ public function getEncoding() * Set SOAP version * * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants - * @return \Zend\Soap\Server\Server - * @throws \Zend\Soap\Server\Exception with invalid soap version argument + * @return \Zend\Soap\Server + * @throws \Zend\Soap\ServerException with invalid soap version argument */ public function setSoapVersion($version) { if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) { - throw new Exception('Invalid soap version specified'); + throw new ServerException('Invalid soap version specified'); } $this->_soapVersion = $version; @@ -325,13 +327,13 @@ public function getSoapVersion() * * @param string $urn * @return true - * @throws \Zend\Soap\Server\Exception on invalid URN + * @throws \Zend\Soap\ServerException on invalid URN */ public function validateUrn($urn) { $scheme = parse_url($urn, PHP_URL_SCHEME); if ($scheme === false || $scheme === null) { - throw new Exception('Invalid URN'); + throw new ServerException('Invalid URN'); } return true; @@ -343,7 +345,7 @@ public function validateUrn($urn) * Actor is the actor URI for the server. * * @param string $actor - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setActor($actor) { @@ -368,8 +370,8 @@ public function getActor() * URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'. * * @param string $uri - * @return \Zend\Soap\Server\Server - * @throws \Zend\Soap\Server\Exception with invalid uri argument + * @return \Zend\Soap\Server + * @throws \Zend\Soap\ServerException with invalid uri argument */ public function setUri($uri) { @@ -392,17 +394,17 @@ public function getUri() * Set classmap * * @param array $classmap - * @return \Zend\Soap\Server\Server - * @throws \Zend\Soap\Server\Exception for any invalid class in the class map + * @return \Zend\Soap\Server + * @throws \Zend\Soap\ServerException for any invalid class in the class map */ public function setClassmap($classmap) { if (!is_array($classmap)) { - throw new Exception('Classmap must be an array'); + throw new ServerException('Classmap must be an array'); } foreach ($classmap as $type => $class) { if (!class_exists($class)) { - throw new Exception('Invalid class in class map'); + throw new ServerException('Invalid class in class map'); } } @@ -424,7 +426,7 @@ public function getClassmap() * Set wsdl * * @param string $wsdl URI or path to a WSDL - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setWSDL($wsdl) { @@ -446,7 +448,7 @@ public function getWSDL() * Set the SOAP Feature options. * * @param string|int $feature - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setSoapFeatures($feature) { @@ -468,7 +470,7 @@ public function getSoapFeatures() * Set the SOAP WSDL Caching Options * * @param string|int|boolean $caching - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setWSDLCache($options) { @@ -490,8 +492,8 @@ public function getWSDLCache() * @param array|string $function Function name, array of function names to attach, * or SOAP_FUNCTIONS_ALL to attach all functions * @param string $namespace Ignored - * @return \Zend\Soap\Server\Server - * @throws \Zend\Soap\Server\Exception on invalid functions + * @return \Zend\Soap\Server + * @throws \Zend\Soap\ServerException on invalid functions */ public function addFunction($function, $namespace = '') { @@ -505,7 +507,7 @@ public function addFunction($function, $namespace = '') if (is_string($func) && function_exists($func)) { $this->_functions[] = $func; } else { - throw new Exception('One or more invalid functions specified in array'); + throw new ServerException('One or more invalid functions specified in array'); } } $this->_functions = array_merge($this->_functions, $function); @@ -514,7 +516,7 @@ public function addFunction($function, $namespace = '') } elseif ($function == SOAP_FUNCTIONS_ALL) { $this->_functions = SOAP_FUNCTIONS_ALL; } else { - throw new Exception('Invalid function specified'); + throw new ServerException('Invalid function specified'); } if (is_array($this->_functions)) { @@ -533,22 +535,22 @@ public function addFunction($function, $namespace = '') * See {@link setObject()} to set preconfigured object instances as request handlers. * * @param string $class Class Name which executes SOAP Requests at endpoint. - * @return \Zend\Soap\Server\Server - * @throws \Zend\Soap\Server\Exception if called more than once, or if class + * @return \Zend\Soap\Server + * @throws \Zend\Soap\ServerException if called more than once, or if class * does not exist */ public function setClass($class, $namespace = '', $argv = null) { if (isset($this->_class)) { - throw new Exception('A class has already been registered with this soap server instance'); + throw new ServerException('A class has already been registered with this soap server instance'); } if (!is_string($class)) { - throw new Exception('Invalid class argument (' . gettype($class) . ')'); + throw new ServerException('Invalid class argument (' . gettype($class) . ')'); } if (!class_exists($class)) { - throw new Exception('Class "' . $class . '" does not exist'); + throw new ServerException('Class "' . $class . '" does not exist'); } $this->_class = $class; @@ -567,16 +569,16 @@ public function setClass($class, $namespace = '', $argv = null) * Accepts an instanciated object to use when handling requests. * * @param object $object - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setObject($object) { if(!is_object($object)) { - throw new Exception('Invalid object argument ('.gettype($object).')'); + throw new ServerException('Invalid object argument ('.gettype($object).')'); } if(isset($this->_object)) { - throw new Exception('An object has already been registered with this soap server instance'); + throw new ServerException('An object has already been registered with this soap server instance'); } $this->_object = $object; @@ -611,23 +613,23 @@ public function getFunctions() * * @param array $array * @return void - * @throws \Zend\Soap\Server\Exception Unimplemented + * @throws \Zend\Soap\ServerException Unimplemented */ public function loadFunctions($definition) { - throw new Exception('Unimplemented'); + throw new ServerException('Unimplemented'); } /** * Set server persistence * * @param int $mode - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setPersistence($mode) { if (!in_array($mode, array(SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST))) { - throw new Exception('Invalid persistence mode specified'); + throw new ServerException('Invalid persistence mode specified'); } $this->_persistence = $mode; @@ -637,7 +639,7 @@ public function setPersistence($mode) /** * Get server persistence * - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function getPersistence() { @@ -655,7 +657,7 @@ public function getPersistence() * - string; if so, verifies XML * * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ protected function _setRequest($request) { @@ -674,7 +676,7 @@ protected function _setRequest($request) $dom = new \DOMDocument(); if(strlen($xml) == 0 || !$dom->loadXML($xml)) { - throw new Exception('Invalid XML'); + throw new ServerException('Invalid XML'); } } $this->_request = $xml; @@ -700,7 +702,7 @@ public function getLastRequest() * The response is always available via {@link getResponse()}. * * @param boolean $flag - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function setReturnResponse($flag) { @@ -788,7 +790,7 @@ public function handle($request = null) $request = file_get_contents('php://input'); } - // Set \Zend\Soap\Server\Server error handler + // Set \Zend\Soap\Server error handler $displayErrorsOriginalState = $this->_initializeSoapErrorContext(); $setRequestException = null; @@ -843,7 +845,7 @@ protected function _initializeSoapErrorContext() * Register a valid fault exception * * @param string|array $class Exception class or array of exception classes - * @return \Zend\Soap\Server\Server + * @return \Zend\Soap\Server */ public function registerFaultException($class) { diff --git a/src/Server/Exception.php b/src/ServerException.php similarity index 90% rename from src/Server/Exception.php rename to src/ServerException.php index 8bf94c20..1fee394e 100644 --- a/src/Server/Exception.php +++ b/src/ServerException.php @@ -22,10 +22,10 @@ /** * @namespace */ -namespace Zend\Soap\Server; +namespace Zend\Soap; /** - * @uses \Zend\Exception + * @uses \Zend\Soap\Exception * @category Zend * @package Zend_Soap * @subpackage Server @@ -33,6 +33,6 @@ * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -class Exception extends \Zend\Exception +class ServerException extends Exception {} diff --git a/src/WSDL/WSDL.php b/src/WSDL.php similarity index 95% rename from src/WSDL/WSDL.php rename to src/WSDL.php index 19b929fe..9ee79755 100644 --- a/src/WSDL/WSDL.php +++ b/src/WSDL.php @@ -22,15 +22,16 @@ /** * @namespace */ -namespace Zend\Soap\WSDL; +namespace Zend\Soap; + use Zend\URI\URL; /** - * \Zend\Soap\WSDL\WSDL + * \Zend\Soap\WSDL * * @uses DOMDocument * @uses \Zend\Server\Exception - * @uses \Zend\Soap\WSDL\Exception + * @uses \Zend\Soap\WSDLException * @uses \Zend\Soap\WSDL\Strategy\AbstractStrategy * @uses \Zend\Soap\WSDL\Strategy\AnyType * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType @@ -80,7 +81,7 @@ class WSDL * * @param string $name Name of the Web Service being Described * @param string|\Zend\URL $uri URI where the WSDL will be available - * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy */ public function __construct($name, $uri, $strategy = true) { @@ -103,7 +104,7 @@ public function __construct($name, $uri, $strategy = true) xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>"; $this->_dom = new \DOMDocument(); if (!$this->_dom->loadXML($wsdl)) { - throw new Exception('Unable to create DomDocument'); + throw new WSDLException('Unable to create DomDocument'); } else { $this->_wsdl = $this->_dom->documentElement; } @@ -115,7 +116,7 @@ public function __construct($name, $uri, $strategy = true) * Set a new uri for this WSDL * * @param string|\Zend\URL $uri - * @return \Zend\Server\WSDL\WSDL + * @return \Zend\Server\WSDL */ public function setUri($uri) { @@ -140,27 +141,27 @@ public function setUri($uri) * Set a strategy for complex type detection and handling * * @todo Boolean is for backwards compability with extractComplexType object var. Remove it in later versions. - * @param boolean|string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy - * @return \Zend\Soap\WSDL\WSDL + * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy + * @return \Zend\Soap\WSDL */ public function setComplexTypeStrategy($strategy) { if($strategy === true) { - $strategy = new Strategy\DefaultComplexType(); + $strategy = new WSDL\Strategy\DefaultComplexType(); } else if($strategy === false) { - $strategy = new Strategy\AnyType(); + $strategy = new WSDL\Strategy\AnyType(); } else if(is_string($strategy)) { if(class_exists($strategy)) { $strategy = new $strategy(); } else { - throw new Exception( + throw new WSDLException( sprintf("Strategy with name '%s does not exist.", $strategy )); } } - if(!($strategy instanceof Strategy\StrategyInterface)) { - throw new Exception("Set a strategy that is not of type 'Zend_Soap_WSDL_Strategy_Interface'"); + if(!($strategy instanceof WSDL\Strategy)) { + throw new WSDLException("Set a strategy that is not of type 'Zend\Soap\WSDL\Strategy'"); } $this->_strategy = $strategy; return $this; @@ -169,7 +170,7 @@ public function setComplexTypeStrategy($strategy) /** * Get the current complex type strategy * - * @return \Zend\Soap\WSDL\Strategy\StrategyInterface + * @return \Zend\Soap\WSDL\Strategy */ public function getComplexTypeStrategy() { @@ -456,7 +457,7 @@ public function addTypes($types) * Add a complex type name that is part of this WSDL and can be used in signatures. * * @param string $type - * @return \Zend\Soap\WSDL\WSDL + * @return \Zend\Soap\WSDL */ public function addType($type) { @@ -570,7 +571,7 @@ public function getType($type) /** * This function makes sure a complex types section and schema additions are set. * - * @return \Zend\Soap\WSDL\WSDL + * @return \Zend\Soap\WSDL */ public function addSchemaTypeSection() { @@ -612,7 +613,7 @@ public function addComplexType($type) private function _parseElement($element) { if (!is_array($element)) { - throw new Exception("The 'element' parameter needs to be an associative array."); + throw new WSDLException("The 'element' parameter needs to be an associative array."); } $elementXml = $this->_dom->createElement('xsd:element'); diff --git a/src/WSDL/Strategy/StrategyInterface.php b/src/WSDL/Strategy.php similarity index 91% rename from src/WSDL/Strategy/StrategyInterface.php rename to src/WSDL/Strategy.php index 9e0036e4..d0f2e683 100644 --- a/src/WSDL/Strategy/StrategyInterface.php +++ b/src/WSDL/Strategy.php @@ -23,7 +23,7 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\WSDL; /** * Interface for Zend_Soap_WSDL_Strategy. @@ -34,14 +34,14 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -interface StrategyInterface +interface Strategy { /** * Method accepts the current WSDL context file. * * @param $context */ - public function setContext(\Zend\Soap\WSDL\WSDL $context); + public function setContext(\Zend\Soap\WSDL $context); /** * Create a complex type based on a strategy diff --git a/src/WSDL/Strategy/AbstractStrategy.php b/src/WSDL/Strategy/AbstractStrategy.php index 263d94a9..0472c594 100644 --- a/src/WSDL/Strategy/AbstractStrategy.php +++ b/src/WSDL/Strategy/AbstractStrategy.php @@ -25,6 +25,8 @@ */ namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap\WSDL\Strategy; + /** * Abstract class for Zend_Soap_WSDL_Strategy. * @@ -35,22 +37,22 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -abstract class AbstractStrategy implements StrategyInterface +abstract class AbstractStrategy implements Strategy { /** * Context object * - * @var \Zend\Soap\WSDL\WSDL + * @var \Zend\Soap\WSDL */ protected $_context; /** * Set the Zend_Soap_WSDL Context object this strategy resides in. * - * @param \Zend\Soap\WSDL\WSDL $context + * @param \Zend\Soap\WSDL $context * @return void */ - public function setContext(\Zend\Soap\WSDL\WSDL $context) + public function setContext(\Zend\Soap\WSDL $context) { $this->_context = $context; } @@ -58,7 +60,7 @@ public function setContext(\Zend\Soap\WSDL\WSDL $context) /** * Return the current Zend_Soap_WSDL context object * - * @return \Zend\Soap\WSDL\WSDL + * @return \Zend\Soap\WSDL */ public function getContext() { diff --git a/src/WSDL/Strategy/AnyType.php b/src/WSDL/Strategy/AnyType.php index 90127b13..c435e0e7 100644 --- a/src/WSDL/Strategy/AnyType.php +++ b/src/WSDL/Strategy/AnyType.php @@ -25,6 +25,8 @@ */ namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap\WSDL\Strategy; + /** * Zend_Soap_WSDL_Strategy_AnyType * @@ -35,14 +37,14 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class AnyType implements StrategyInterface +class AnyType implements Strategy { /** * Not needed in this strategy. * - * @param \Zend\Soap\WSDL\WSDL $context + * @param \Zend\Soap\WSDL $context */ - public function setContext(\Zend\Soap\WSDL\WSDL $context) + public function setContext(\Zend\Soap\WSDL $context) { } diff --git a/src/WSDL/Strategy/ArrayOfTypeComplex.php b/src/WSDL/Strategy/ArrayOfTypeComplex.php index 680a807b..edbe2d32 100644 --- a/src/WSDL/Strategy/ArrayOfTypeComplex.php +++ b/src/WSDL/Strategy/ArrayOfTypeComplex.php @@ -24,7 +24,8 @@ * @namespace */ namespace Zend\Soap\WSDL\Strategy; -use Zend\Soap\WSDL; + +use Zend\Soap\WSDLException; /** * Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex @@ -50,14 +51,14 @@ class ArrayOfTypeComplex extends DefaultComplexType public function addComplexType($type) { if(in_array($type, $this->_inProcess)) { - throw new WSDL\Exception("Infinite recursion, cannot nest '$type' into itself."); + throw new WSDLException("Infinite recursion, cannot nest '$type' into itself."); } $this->_inProcess[$type] = $type; $nestingLevel = $this->_getNestedCount($type); if($nestingLevel > 1) { - throw new WSDL\Exception( + throw new WSDLException( 'ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ' . 'one level. Use array object properties to return deep nested data.' ); @@ -66,7 +67,7 @@ public function addComplexType($type) $singularType = $this->_getSingularPhpType($type); if(!class_exists($singularType)) { - throw new WSDL\Exception(sprintf( + throw new WSDLException(sprintf( 'Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type )); diff --git a/src/WSDL/Strategy/ArrayOfTypeSequence.php b/src/WSDL/Strategy/ArrayOfTypeSequence.php index 1cbb35d8..dc5806a1 100644 --- a/src/WSDL/Strategy/ArrayOfTypeSequence.php +++ b/src/WSDL/Strategy/ArrayOfTypeSequence.php @@ -102,7 +102,7 @@ protected function _getStrippedXsdType($singularType) /** * From a nested defintion with type[], get the singular xsd:type * - * @throws \Zend\Soap\WSDL\Exception When no xsd:simpletype can be detected. + * @throws \Zend\Soap\WSDLException When no xsd:simpletype can be detected. * @param string $type * @return string */ diff --git a/src/WSDL/Strategy/Composite.php b/src/WSDL/Strategy/Composite.php index 8818df57..e2141ed5 100644 --- a/src/WSDL/Strategy/Composite.php +++ b/src/WSDL/Strategy/Composite.php @@ -24,7 +24,10 @@ * @namespace */ namespace Zend\Soap\WSDL\Strategy; -use Zend\Soap\WSDL; + +use Zend\Soap\WSDL\Strategy, + Zend\Soap\WSDLException, + Zend\Soap\WSDL; /** * Zend_Soap_WSDL_Strategy_Composite @@ -37,7 +40,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Composite implements StrategyInterface +class Composite implements Strategy { /** * Typemap of Complex Type => Strategy pairs. @@ -49,25 +52,25 @@ class Composite implements StrategyInterface /** * Default Strategy of this composite * - * @var string|\Zend\Soap\WSDL\Strategy\StrategyInterface + * @var string|\Zend\Soap\WSDL\Strategy */ protected $_defaultStrategy; /** * Context WSDL file that this composite serves * - * @var \Zend\Soap\WSDL\WSDL|null + * @var \Zend\Soap\WSDL|null */ protected $_context; /** * Construct Composite WSDL Strategy. * - * @throws \Zend\Soap\WSDL\Exception + * @throws \Zend\Soap\WSDLException * @param array $typeMap - * @param string|\Zend\Soap\WSDL\Strategy\StrategyInterface $defaultStrategy + * @param string|\Zend\Soap\WSDL\Strategy $defaultStrategy */ - public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_WSDL_Strategy_DefaultComplexType") + public function __construct(array $typeMap=array(), $defaultStrategy="Zend\Soap\WSDL\Strategy\DefaultComplexType") { foreach($typeMap AS $type => $strategy) { $this->connectTypeToStrategy($type, $strategy); @@ -80,13 +83,13 @@ public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_ * * @throws \Zend\Soap\WSDL\Exception * @param string $type - * @param string|\Zend\Soap\WSDL\Strategy\StrategyInterface $strategy + * @param string|\Zend\Soap\WSDL\Strategy $strategy * @return \Zend\Soap\WSDL\Strategy\Composite */ public function connectTypeToStrategy($type, $strategy) { if(!is_string($type)) { - throw new WSDL\Exception('Invalid type given to Composite Type Map.'); + throw new WSDLException('Invalid type given to Composite Type Map.'); } $this->_typeMap[$type] = $strategy; return $this; @@ -95,9 +98,9 @@ public function connectTypeToStrategy($type, $strategy) /** * Return default strategy of this composite * - * @throws \Zend\Soap\WSDL\Exception + * @throws \Zend\Soap\WSDLException * @param string $type - * @return \Zend\Soap\WSDL\Strategy\StrategyInterface + * @return \Zend\Soap\WSDL\Strategy */ public function getDefaultStrategy() { @@ -105,8 +108,8 @@ public function getDefaultStrategy() if(is_string($strategy) && class_exists($strategy)) { $strategy = new $strategy; } - if( !($strategy instanceof StrategyInterface) ) { - throw new WSDL\Exception( + if( !($strategy instanceof Strategy) ) { + throw new WSDLException( 'Default Strategy for Complex Types is not a valid strategy object.' ); } @@ -117,9 +120,9 @@ public function getDefaultStrategy() /** * Return specific strategy or the default strategy of this type. * - * @throws \Zend\Soap\WSDL\Exception + * @throws \Zend\Soap\WSDLException * @param string $type - * @return \Zend\Soap\WSDL\Strategy\StrategyInterface + * @return \Zend\Soap\WSDL\Strategy */ public function getStrategyOfType($type) { @@ -130,8 +133,8 @@ public function getStrategyOfType($type) $strategy = new $strategy(); } - if( !($strategy instanceof StrategyInterface) ) { - throw new WSDL\Exception( + if( !($strategy instanceof Strategy) ) { + throw new WSDLException( "Strategy for Complex Type '$type' is not a valid strategy object." ); } @@ -145,9 +148,9 @@ public function getStrategyOfType($type) /** * Method accepts the current WSDL context file. * - * @param \Zend\Soap\WSDL\WSDL $context + * @param \Zend\Soap\WSDL $context */ - public function setContext(WSDL\WSDL $context) + public function setContext(WSDL $context) { $this->_context = $context; return $this; @@ -156,14 +159,14 @@ public function setContext(WSDL\WSDL $context) /** * Create a complex type based on a strategy * - * @throws \Zend\Soap\WSDL\Exception + * @throws \Zend\Soap\WSDLException * @param string $type * @return string XSD type */ public function addComplexType($type) { - if(!($this->_context instanceof WSDL\WSDL) ) { - throw new WSDL\Exception( + if(!($this->_context instanceof WSDL) ) { + throw new WSDLException( "Cannot add complex type '$type', no context is set for this composite strategy." ); } diff --git a/src/WSDL/Strategy/DefaultComplexType.php b/src/WSDL/Strategy/DefaultComplexType.php index 76bce886..0a9dd642 100644 --- a/src/WSDL/Strategy/DefaultComplexType.php +++ b/src/WSDL/Strategy/DefaultComplexType.php @@ -25,11 +25,13 @@ */ namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap\WSDLException; + /** * Zend_Soap_WSDL_Strategy_DefaultComplexType * * @uses ReflectionClass - * @uses \Zend\Soap\WSDL\Exception + * @uses \Zend\Soap\WSDLException * @uses \Zend\Soap\WSDL\Strategy\AbstractStrategy * @category Zend * @package Zend_Soap @@ -48,7 +50,7 @@ class DefaultComplexType extends AbstractStrategy public function addComplexType($type) { if(!class_exists($type)) { - throw new \Zend\Soap\WSDL\Exception(sprintf( + throw new WSDLException(sprintf( 'Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type )); diff --git a/src/WSDL/Exception.php b/src/WSDLException.php similarity index 90% rename from src/WSDL/Exception.php rename to src/WSDLException.php index c7a13db2..71b8c010 100644 --- a/src/WSDL/Exception.php +++ b/src/WSDLException.php @@ -23,16 +23,16 @@ /** * @namespace */ -namespace Zend\Soap\WSDL; +namespace Zend\Soap; /** * Zend_Soap_WSDL_Exception * - * @uses \Zend\Exception + * @uses \Zend\Soap\Exception * @category Zend * @package Zend_Soap * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Exception extends \Zend\Exception { } +class WSDLException extends Exception { } diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index 1fb221e1..14b50f7c 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -56,7 +56,7 @@ public function testNestedObjectArrayResponse() $b->bar = "test"; $b->foo = "test"; - $client = new Client\Client($wsdl); + $client = new Client($wsdl); $ret = $client->request($b); $this->assertTrue( is_array($ret) ); @@ -77,7 +77,7 @@ public function testObjectResponse() { $wsdl = $this->baseuri."/server2.php?wsdl"; - $client = new Client\Client($wsdl); + $client = new Client($wsdl); $ret = $client->request("test", "test"); $this->assertTrue( ($ret instanceof \stdClass) ); diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index d2baf5d8..1dcdd533 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -28,8 +28,8 @@ /** Include Common TestTypes */ require_once 'TestAsset/commontypes.php'; -use Zend\Soap\AutoDiscover\AutoDiscover, - Zend\Soap\AutoDiscover\Exception as AutoDiscoverException; +use Zend\Soap\AutoDiscover, + Zend\Soap\AutoDiscoverException; /** PHPUnit Test Case */ diff --git a/test/ClientTest.php b/test/ClientTest.php index 5dc82941..92b51924 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -63,7 +63,7 @@ public function testSetOptions() /************************************************************* * ------ Test WSDL mode options ----------------------------- *************************************************************/ - $client = new Client\Client(); + $client = new Client(); $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); @@ -102,7 +102,7 @@ public function testSetOptions() /************************************************************* * ------ Test non-WSDL mode options ----------------------------- *************************************************************/ - $client1 = new Client\Client(); + $client1 = new Client(); $this->assertTrue($client1->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); @@ -133,7 +133,7 @@ public function testSetOptions() public function testGetOptions() { - $client = new Client\Client(); + $client = new Client(); $this->assertTrue($client->getOptions() == array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2)); @@ -170,7 +170,7 @@ public function testGetOptions() */ public function testGetAndSetUserAgentOption() { - $client = new Client\Client(); + $client = new Client(); $this->assertNull($client->getUserAgent()); $client->setUserAgent('agent1'); @@ -200,7 +200,7 @@ public function testGetAndSetUserAgentOption() */ public function testUserAgentAllowsEmptyString() { - $client = new Client\Client(); + $client = new Client(); $this->assertNull($client->getUserAgent()); $options = $client->getOptions(); $this->assertArrayNotHasKey('user_agent', $options); @@ -218,7 +218,7 @@ public function testUserAgentAllowsEmptyString() public function testGetFunctions() { - $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); $server->setClass('ZendTest_Soap_TestAsset_TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -247,7 +247,7 @@ public function testGetLastRequest() return; } - $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); $server->setClass('ZendTest_Soap_TestAsset_TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -277,7 +277,7 @@ public function testGetLastResponse() return; } - $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); $server->setClass('ZendTest_Soap_TestAsset_TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -308,7 +308,7 @@ public function testCallInvoke() return; } - $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); $server->setClass('ZendTest_Soap_TestAsset_TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -347,7 +347,7 @@ public function testSetOptionsWithZendConfig() $config = new \Zend\Config\Config($nonWSDLOptions); - $client = new Client\Client(null, $config); + $client = new Client(null, $config); $this->assertEquals($nonWSDLOptions, $client->getOptions()); } @@ -359,7 +359,7 @@ public function testSetInputHeaders() return; } - $server = new Server\Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); + $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); $server->setClass('ZendTest_Soap_TestAsset_TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -458,7 +458,7 @@ public function testSetCookieIsDelegatedToSoapClient() ->method('__setCookie') ->with($fixtureCookieKey, $fixtureCookieValue); - $soap = new Client\Client(); + $soap = new Client(); $soap->setSoapClient($clientMock); $soap->setCookie($fixtureCookieKey, $fixtureCookieValue); @@ -468,7 +468,7 @@ public function testSetSoapClient() { $clientMock = $this->getMock('SoapClient', array('__setCookie'), array(null, array('uri' => 'http://www.zend.com', 'location' => 'http://www.zend.com'))); - $soap = new Client\Client(); + $soap = new Client(); $soap->setSoapClient($clientMock); $this->assertSame($clientMock, $soap->getSoapClient()); diff --git a/test/ServerTest.php b/test/ServerTest.php index 32a61bc3..5c8392fa 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -27,7 +27,8 @@ require_once __DIR__ . '/TestAsset/commontypes.php'; -use Zend\Soap\Server; +use Zend\Soap\Server, + Zend\Soap\ServerException; /** * Zend_Soap_Server @@ -52,7 +53,7 @@ public function setUp() public function testSetOptions() { - $server = new Server\Server(); + $server = new Server(); $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); @@ -80,14 +81,14 @@ public function testSetOptionsViaSecondConstructorArgument() 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', ); - $server = new Server\Server(null, $options); + $server = new Server(null, $options); $this->assertTrue($server->getOptions() == $options); } public function testSetWSDLViaOptionsArrayIsPossible() { - $server = new Server\Server(); + $server = new Server(); $server->setOptions(array('wsdl' => 'http://www.example.com/test.wsdl')); $this->assertEquals('http://www.example.com/test.wsdl', $server->getWSDL()); @@ -95,7 +96,7 @@ public function testSetWSDLViaOptionsArrayIsPossible() public function testGetOptions() { - $server = new Server\Server(); + $server = new Server(); $this->assertTrue($server->getOptions() == array('soap_version' => SOAP_1_2)); @@ -109,7 +110,7 @@ public function testGetOptions() public function testEncoding() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getEncoding()); $server->setEncoding('ISO-8859-1'); @@ -125,7 +126,7 @@ public function testEncoding() public function testSoapVersion() { - $server = new Server\Server(); + $server = new Server(); $this->assertEquals(SOAP_1_2, $server->getSoapVersion()); $server->setSoapVersion(SOAP_1_1); @@ -140,7 +141,7 @@ public function testSoapVersion() public function testValidateUrn() { - $server = new Server\Server(); + $server = new Server(); try { $server->validateUrn('bogosity'); @@ -155,7 +156,7 @@ public function testValidateUrn() public function testSetActor() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); @@ -170,7 +171,7 @@ public function testSetActor() public function testGetActor() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); @@ -179,7 +180,7 @@ public function testGetActor() public function testSetUri() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); @@ -194,7 +195,7 @@ public function testSetUri() public function testGetUri() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); @@ -203,7 +204,7 @@ public function testGetUri() public function testSetClassmap() { - $server = new Server\Server(); + $server = new Server(); $classmap = array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2'); @@ -227,7 +228,7 @@ public function testSetClassmap() public function testGetClassmap() { - $server = new Server\Server(); + $server = new Server(); $classmap = array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2'); @@ -239,7 +240,7 @@ public function testGetClassmap() public function testSetWSDL() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getWSDL()); $server->setWSDL(dirname(__FILE__).'/_files/wsdl_example.wsdl'); @@ -254,7 +255,7 @@ public function testSetWSDL() public function testGetWSDL() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getWSDL()); $server->setWSDL(dirname(__FILE__).'/_files/wsdl_example.wsdl'); @@ -263,7 +264,7 @@ public function testGetWSDL() public function testAddFunction() { - $server = new Server\Server(); + $server = new Server(); // Correct function should pass $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); @@ -282,30 +283,30 @@ public function testAddFunction() public function testAddBogusFunctionAsInteger() { - $server = new Server\Server(); + $server = new Server(); try { $server->addFunction(126); $this->fail('Invalid value should fail'); - } catch (Server\Exception $e) { + } catch (ServerException $e) { // success } } public function testAddBogusFunctionsAsString() { - $server = new Server\Server(); + $server = new Server(); try { $server->addFunction('bogus_function'); $this->fail('Invalid function should fail.'); - } catch (Server\Exception $e) { + } catch (ServerException $e) { // success } } public function testAddBogusFunctionsAsArray() { - $server = new Server\Server(); + $server = new Server(); try { $functions = array('ZendTest_Soap_TestAsset_TestFunc5', @@ -313,14 +314,14 @@ public function testAddBogusFunctionsAsArray() 'ZendTest_Soap_TestAsset_TestFunc6'); $server->addFunction($functions); $this->fail('Invalid function within a set of functions should fail'); - } catch (Server\Exception $e) { + } catch (ServerException $e) { // success } } public function testAddAllFunctionsSoapConstant() { - $server = new Server\Server(); + $server = new Server(); // SOAP_FUNCTIONS_ALL as a value should pass $server->addFunction(SOAP_FUNCTIONS_ALL); @@ -330,7 +331,7 @@ public function testAddAllFunctionsSoapConstant() public function testSetClass() { - $server = new Server\Server(); + $server = new Server(); // Correct class name should pass try { @@ -342,21 +343,21 @@ public function testSetClass() public function testSetClassTwiceThrowsException() { - $server = new Server\Server(); + $server = new Server(); // Correct class name should pass try { $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $this->fail(); - } catch(Server\Exception $e) { + } catch(ServerException $e) { $this->assertEquals('A class has already been registered with this soap server instance', $e->getMessage()); } } public function testSetClassWithArguments() { - $server = new Server\Server(); + $server = new Server(); // Correct class name should pass try { @@ -368,7 +369,7 @@ public function testSetClassWithArguments() public function testSetBogusClassWithIntegerName() { - $server = new Server\Server(); + $server = new Server(); try { $server->setClass(465); @@ -380,7 +381,7 @@ public function testSetBogusClassWithIntegerName() public function testSetBogusClassWithUnknownClassName() { - $server = new Server\Server(); + $server = new Server(); try { $server->setClass('Zend_Soap_Server_Test_BogusClass'); @@ -395,7 +396,7 @@ public function testSetBogusClassWithUnknownClassName() */ public function testSetObject() { - $server = new Server\Server(); + $server = new Server(); try { $server->setObject(465); @@ -425,7 +426,7 @@ public function testSetObject() public function testGetFunctions() { - $server = new Server\Server(); + $server = new Server(); $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); @@ -452,7 +453,7 @@ public function testGetFunctions() public function testGetFunctionsWithClassAttached() { - $server = new Server\Server(); + $server = new Server(); $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); $this->assertEquals( @@ -463,7 +464,7 @@ public function testGetFunctionsWithClassAttached() public function testGetFunctionsWithObjectAttached() { - $server = new Server\Server(); + $server = new Server(); $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); $this->assertEquals( @@ -474,7 +475,7 @@ public function testGetFunctionsWithObjectAttached() public function testSetPersistence() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getPersistence()); $server->setPersistence(SOAP_PERSISTENCE_SESSION); @@ -492,19 +493,19 @@ public function testSetPersistence() public function testSetUnknownPersistenceStateThrowsException() { - $server = new Server\Server(); + $server = new Server(); try { $server->setPersistence('bogus'); $this->fail(); - } catch(Server\Exception $e) { + } catch(ServerException $e) { } } public function testGetPersistence() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getPersistence()); $server->setPersistence(SOAP_PERSISTENCE_SESSION); @@ -518,7 +519,7 @@ public function testGetLastRequest() return; } - $server = new Server\Server(); + $server = new Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -546,7 +547,7 @@ public function testGetLastRequest() public function testSetReturnResponse() { - $server = new Server\Server(); + $server = new Server(); $this->assertFalse($server->getReturnResponse()); @@ -559,7 +560,7 @@ public function testSetReturnResponse() public function testGetReturnResponse() { - $server = new Server\Server(); + $server = new Server(); $this->assertFalse($server->getReturnResponse()); @@ -574,7 +575,7 @@ public function testGetLastResponse() return; } - $server = new Server\Server(); + $server = new Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -626,7 +627,7 @@ public function testHandle() return; } - $server = new Server\Server(); + $server = new Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); @@ -670,7 +671,7 @@ public function testHandle() . '' . '' . "\n"; - $server1 = new Server\Server(); + $server1 = new Server(); $server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server1->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); @@ -684,7 +685,7 @@ public function testHandle() */ public function testRegisterFaultException() { - $server = new Server\Server(); + $server = new Server(); $server->registerFaultException("Zend_Soap_Server_Exception"); $server->registerFaultException(array("OutOfBoundsException", "BogusException")); @@ -701,7 +702,7 @@ public function testRegisterFaultException() */ public function testDeregisterFaultException() { - $server = new Server\Server(); + $server = new Server(); $server->registerFaultException(array("OutOfBoundsException", "BogusException")); $ret = $server->deregisterFaultException("BogusException"); @@ -720,7 +721,7 @@ public function testDeregisterFaultException() */ public function testGetFaultExceptions() { - $server = new Server\Server(); + $server = new Server(); $this->assertEquals(array(), $server->getFaultExceptions()); $server->registerFaultException("Exception"); @@ -729,7 +730,7 @@ public function testGetFaultExceptions() public function testFaultWithTextMessage() { - $server = new Server\Server(); + $server = new Server(); $fault = $server->fault("Faultmessage!"); $this->assertTrue($fault instanceof \SOAPFault); @@ -738,7 +739,7 @@ public function testFaultWithTextMessage() public function testFaultWithUnregisteredException() { - $server = new Server\Server(); + $server = new Server(); $fault = $server->fault(new \Exception("MyException")); $this->assertTrue($fault instanceof \SOAPFault); @@ -748,7 +749,7 @@ public function testFaultWithUnregisteredException() public function testFaultWithRegisteredException() { - $server = new Server\Server(); + $server = new Server(); $server->registerFaultException("Exception"); $fault = $server->fault(new \Exception("MyException")); @@ -759,7 +760,7 @@ public function testFaultWithRegisteredException() public function testFautlWithBogusInput() { - $server = new Server\Server(); + $server = new Server(); $fault = $server->fault(array("Here", "There", "Bogus")); $this->assertContains("Unknown error", $fault->getMessage()); @@ -770,7 +771,7 @@ public function testFautlWithBogusInput() */ public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault() { - $server = new Server\Server(); + $server = new Server(); $fault = $server->fault("Faultmessage!", 5000); $this->assertTrue($fault instanceof \SOAPFault); @@ -781,7 +782,7 @@ public function testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault() */ public function testHandlePhpErrors() { - $server = new Server\Server(); + $server = new Server(); // Remove the following line when you implement this test. $this->markTestIncomplete( @@ -791,12 +792,12 @@ public function testHandlePhpErrors() public function testLoadFunctionsIsNotImplemented() { - $server = new Server\Server(); + $server = new Server(); try { $server->loadFunctions("bogus"); $this->fail(); - } catch(Server\Exception $e) { + } catch(ServerException $e) { } } @@ -808,7 +809,7 @@ public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHan return; } - $server = new Server\Server(); + $server = new Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); @@ -849,7 +850,7 @@ public function testServerAcceptsZendConfigObject() ); $config = new \Zend\Config\Config($options); - $server = new Server\Server(); + $server = new Server(); $server->setOptions($config); $this->assertEquals($options, $server->getOptions()); } @@ -859,7 +860,7 @@ public function testServerAcceptsZendConfigObject() */ public function testSetAndGetFeatures() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getSoapFeatures()); $server->setSoapFeatures(100); $this->assertEquals(100, $server->getSoapFeatures()); @@ -873,7 +874,7 @@ public function testSetAndGetFeatures() */ public function testSetAndGetWSDLCache() { - $server = new Server\Server(); + $server = new Server(); $this->assertNull($server->getWSDLCache()); $server->setWSDLCache(100); $this->assertEquals(100, $server->getWSDLCache()); diff --git a/test/TestAsset/commontypes.php b/test/TestAsset/commontypes.php index 25c27e56..7f9e8221 100644 --- a/test/TestAsset/commontypes.php +++ b/test/TestAsset/commontypes.php @@ -621,7 +621,7 @@ class ZendTest_Soap_TestAsset_TestLocalSoapClient extends \SoapClient * @param string $wsdl * @param array $options */ - function __construct(\Zend\Soap\Server\Server $server, $wsdl, $options) + function __construct(\Zend\Soap\Server $server, $wsdl, $options) { $this->server = $server; parent::__construct($wsdl, $options); diff --git a/test/TestAsset/fulltests/server1.php b/test/TestAsset/fulltests/server1.php index 9bf9bf93..e2447fef 100644 --- a/test/TestAsset/fulltests/server1.php +++ b/test/TestAsset/fulltests/server1.php @@ -23,7 +23,7 @@ /** * @namespace */ -namespace ZendTest\Soap\_files\fulltests; +namespace ZendTest\Soap\TestAsset\fulltests; /** * @category Zend @@ -35,8 +35,8 @@ class Server1 { /** - * @param \ZendTest\Soap\_files\fulltests\ComplexTypeB - * @return \ZendTest\Soap\_files\fulltests\ComplexTypeA[] + * @param \ZendTest\Soap\TestAsset\fulltests\ComplexTypeB + * @return \ZendTest\Soap\TestAsset\fulltests\ComplexTypeA[] */ public function request($request) { @@ -87,16 +87,16 @@ class ComplexTypeB class ComplexTypeA { /** - * @var \ZendTest\Soap\_files\fulltests\ComplexTypeB[] + * @var \ZendTest\Soap\TestAsset\fulltests\ComplexTypeB[] */ public $baz = array(); } if(isset($_GET['wsdl'])) { - $server = new \Zend\Soap\AutoDiscover\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); + $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; - $server = new \Zend\Soap\Server\Server($uri); + $server = new \Zend\Soap\Server($uri); } -$server->setClass('\ZendTest\Soap\_files\fulltests\Server1'); +$server->setClass('\ZendTest\Soap\TestAsset\fulltests\Server1'); $server->handle(); diff --git a/test/TestAsset/fulltests/server2.php b/test/TestAsset/fulltests/server2.php index daea8e47..095350ac 100644 --- a/test/TestAsset/fulltests/server2.php +++ b/test/TestAsset/fulltests/server2.php @@ -23,7 +23,7 @@ /** * @namespace */ -namespace ZendTest\Soap\_files\fulltests; +namespace ZendTest\Soap\TestAsset\fulltests; /** * @category Zend @@ -56,7 +56,7 @@ class Server2 /** * @param string $foo * @param string $bar - * @return \ZendTest\Soap\_files\fulltests\ComplexTypeB + * @return \ZendTest\Soap\TestAsset\fulltests\ComplexTypeB */ public function request($foo, $bar) { @@ -68,10 +68,10 @@ public function request($foo, $bar) } if(isset($_GET['wsdl'])) { - $server = new \Zend\Soap\AutoDiscover\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); + $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; - $server = new \Zend\Soap\Server\Server($uri); + $server = new \Zend\Soap\Server($uri); } -$server->setClass('ZendTest\Soap\_files\fulltests\Server2'); +$server->setClass('ZendTest\Soap\TestAsset\fulltests\Server2'); $server->handle(); diff --git a/test/WSDL/ArrayOfTypeComplexStrategyTest.php b/test/WSDL/ArrayOfTypeComplexStrategyTest.php index b310bc98..f7a1e910 100644 --- a/test/WSDL/ArrayOfTypeComplexStrategyTest.php +++ b/test/WSDL/ArrayOfTypeComplexStrategyTest.php @@ -47,18 +47,18 @@ class ArrayOfTypeComplexStrategyTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->strategy = new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex(); - $this->wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); + $this->wsdl = new WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); } public function testNestingObjectsDeepMakesNoSenseThrowingException() { - $this->setExpectedException('Zend\Soap\WSDL\Exception'); + $this->setExpectedException('Zend\Soap\WSDLException'); $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[][]'); } public function testAddComplexTypeOfNonExistingClassThrowsException() { - $this->setExpectedException('Zend\Soap\WSDL\Exception'); + $this->setExpectedException('Zend\Soap\WSDLException'); $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_UnknownClass[]'); } @@ -221,7 +221,7 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllType */ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() { - $this->setExpectedException('Zend\Soap\WSDL\Exception', 'Infinite recursion'); + $this->setExpectedException('Zend\Soap\WSDLException', 'Infinite recursion'); $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_Recursion"); } } diff --git a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php index 79339f48..e9400848 100644 --- a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php +++ b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php @@ -43,7 +43,7 @@ class ArrayOfTypeSequenceStrategyTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->strategy = new \Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence(); - $this->wsdl = new \Zend\Soap\WSDL\WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); + $this->wsdl = new \Zend\Soap\WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); } public function testFunctionReturningSimpleArrayOfInts() @@ -151,9 +151,8 @@ public function testAddComplexTypeArrayOfObject() public function testAddComplexTypeOfNonExistingClassThrowsException() { - $this->setExpectedException('\Zend\Soap\WSDL\Exception'); - - $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\UnknownClass[]'); + $this->setExpectedException('\Zend\Soap\WSDLException'); + $this->wsdl->addComplexType('ZendTest\Soap\WSDL\UnknownClass[]'); } } diff --git a/test/WSDL/CompositeStrategyTest.php b/test/WSDL/CompositeStrategyTest.php index d34cf6fe..c00ec04d 100644 --- a/test/WSDL/CompositeStrategyTest.php +++ b/test/WSDL/CompositeStrategyTest.php @@ -23,8 +23,9 @@ * @namespace */ namespace ZendTest\Soap\WSDL; -use Zend\Soap\WSDL\Strategy; -use Zend\Soap\WSDL; +use Zend\Soap\WSDL\Strategy, + Zend\Soap\WSDL, + Zend\Soap\WSDLException; /** * @package Zend_Soap @@ -78,7 +79,7 @@ public function testCompositeThrowsExceptionOnInvalidType() $strategy->connectTypeToStrategy(array(), 'strategy'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Exception); + $this->assertTrue($e instanceof WSDLException); } } @@ -91,14 +92,14 @@ public function testCompositeThrowsExceptionOnInvalidStrategy() $book = $strategy->getStrategyOfType('Book'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Exception); + $this->assertTrue($e instanceof WSDLException); } try { $book = $strategy->getStrategyOfType('Anything'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Exception); + $this->assertTrue($e instanceof WSDLException); } } @@ -108,7 +109,7 @@ public function testCompositeDelegatesAddingComplexTypesToSubStrategies() $strategy->connectTypeToStrategy('\ZendTest\Soap\WSDL\Book', '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); $strategy->connectTypeToStrategy('\ZendTest\Soap\WSDL\Cookie', '\Zend\Soap\WSDL\Strategy\DefaultComplexType'); - $wsdl = new WSDL\WSDL('SomeService', 'http://example.com'); + $wsdl = new WSDL('SomeService', 'http://example.com'); $strategy->setContext($wsdl); $this->assertEquals('tns:\ZendTest\Soap\WSDL\Book', $strategy->addComplexType('\ZendTest\Soap\WSDL\Book')); @@ -123,7 +124,7 @@ public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrows $strategy->addComplexType('Test'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Exception); + $this->assertTrue($e instanceof WSDLException); } } } diff --git a/test/WSDL/DefaultComplexTypeTest.php b/test/WSDL/DefaultComplexTypeTest.php index 45d8e4d9..1213c13e 100644 --- a/test/WSDL/DefaultComplexTypeTest.php +++ b/test/WSDL/DefaultComplexTypeTest.php @@ -49,7 +49,7 @@ class DefaultComplexTypeTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->strategy = new \Zend\Soap\WSDL\Strategy\DefaultComplexType(); - $this->wsdl = new \Zend\Soap\WSDL\WSDL("TestService", "http://framework.zend.com/soap/unittests"); + $this->wsdl = new \Zend\Soap\WSDL("TestService", "http://framework.zend.com/soap/unittests"); $this->wsdl->setComplexTypeStrategy($this->strategy); $this->strategy->setContext($this->wsdl); } diff --git a/test/WSDL/ElementTest.php b/test/WSDL/ElementTest.php index e1dd96f0..b63bdbaa 100644 --- a/test/WSDL/ElementTest.php +++ b/test/WSDL/ElementTest.php @@ -24,7 +24,8 @@ * @namespace */ namespace ZendTest\Soap\WSDL; -use Zend\Soap\WSDL; +use Zend\Soap\WSDL, + Zend\Soap\WSDLException; /** * @category Zend; @@ -51,7 +52,7 @@ public function testBindingElementApi() try { $binding = new WSDL\Element\Binding(array(), "portName", $operations, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -68,7 +69,7 @@ public function testTypeElementApi() try { $type = new WSDL\Element\Type(array(), $types, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -85,7 +86,7 @@ public function testMessageElementApi() try { $message = new WSDL\Element\Message(array(), $parts, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -102,7 +103,7 @@ public function testPortElementApi() try { $port = new WSDL\Element\Port(array(), $operations, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -123,7 +124,7 @@ public function testOperationElementApi() try { $operation = new WSDL\Element\Operation(array(), $input, $output, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -145,14 +146,14 @@ public function testServiceElementApi() try { $service = new WSDL\Element\Service(array(), "address", $port, $binding, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } try { $service = new WSDL\Element\Service("name", array(), $port, $binding, "test"); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -168,14 +169,14 @@ public function testCollectionElementApiConstruct() $type = new WSDL\Element\Type("type", new WSDL\Element\Collection("Type"), "test"); $collection->addElement($type); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } try { $collection = new WSDL\Element\Collection(false); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -222,7 +223,7 @@ public function testCollectionElementApiElementAccess() // Adding duplicate message leads to exception $collection->addElement($messageDuplicate); $this->fail("Adding a duplicate named element to a collection should throw an exception."); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); $this->assertEquals($message2, $collection->getElement("message2")); $this->assertEquals(2, count($collection)); @@ -232,7 +233,7 @@ public function testCollectionElementApiElementAccess() // Accessing unkown message leads to exception $collection->getElement("messageUnknown"); $this->fail("Accessing unknown element should throw an exception."); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { $this->assertEquals(2, count($collection)); } diff --git a/test/WSDL/ParserTest.php b/test/WSDL/ParserTest.php index 04d94e10..3499913d 100644 --- a/test/WSDL/ParserTest.php +++ b/test/WSDL/ParserTest.php @@ -24,7 +24,8 @@ * @namespace */ namespace ZendTest\Soap\WSDL; -use Zend\Soap\WSDL; +use Zend\Soap\WSDL, + Zend\Soap\WSDLException; /** * @category Zend @@ -69,14 +70,14 @@ public function testFactoryWithSimpleXml() public function testFactoryWithZendSoapWSDL() { - $wsdl = new WSDL\WSDL("name", "http://example.com"); + $wsdl = new WSDL("name", "http://example.com"); $parser = WSDL\Parser::factory($wsdl); $this->assertTrue($parser instanceof WSDL\Parser); } public function testFactoryWithInvalidParser() { - $wsdl = new WSDL\WSDL("name", "http://example.com"); + $wsdl = new WSDL("name", "http://example.com"); try { $parser = WSDL\Parser::factory($wsdl, "stdClass"); $this->fail(); @@ -90,7 +91,7 @@ public function testFactoryWithInvalidData() try { $parser = WSDL\Parser::factory(null); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } diff --git a/test/WSDLTest.php b/test/WSDLTest.php index 668a888c..6507c3b3 100644 --- a/test/WSDLTest.php +++ b/test/WSDLTest.php @@ -24,8 +24,9 @@ * @namespace */ namespace ZendTest\Soap; -use Zend\Soap\WSDL; -use Zend\Soap\WSDL\Strategy; +use Zend\Soap\WSDL, + Zend\Soap\WSDLException, + Zend\Soap\WSDL\Strategy; /** * Test cases for Zend_Soap_WSDL @@ -56,7 +57,7 @@ public function swallowIncludeNotices($errno, $errstr) function testConstructor() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . @@ -71,7 +72,7 @@ function testConstructor() function testSetUriChangesDomDocumentWSDLStructureTnsAndTargetNamespaceAttributes() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->setUri('http://localhost/MyNewService.php'); $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), @@ -87,7 +88,7 @@ function testSetUriChangesDomDocumentWSDLStructureTnsAndTargetNamespaceAttribute function testAddMessage() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $messageParts = array(); $messageParts['parameter1'] = $wsdl->getType('int'); @@ -115,7 +116,7 @@ function testAddMessage() function testAddPortType() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addPortType('myPortType'); @@ -134,7 +135,7 @@ function testAddPortType() function testAddPortOperation() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $portType = $wsdl->addPortType('myPortType'); @@ -168,7 +169,7 @@ function testAddPortOperation() function testAddBinding() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -189,7 +190,7 @@ function testAddBinding() function testAddBindingOperation() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -244,7 +245,7 @@ function testAddBindingOperation() function testAddSoapBinding() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -282,7 +283,7 @@ function testAddSoapBinding() . '' . '' ); - $wsdl1 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl1 = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl1->addPortType('myPortType'); $binding = $wsdl1->addBinding('MyServiceBinding', 'myPortType'); @@ -324,7 +325,7 @@ function testAddSoapBinding() function testAddSoapOperation() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -365,7 +366,7 @@ function testAddSoapOperation() function testAddService() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -393,7 +394,7 @@ function testAddService() function testAddDocumentation() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $portType = $wsdl->addPortType('myPortType'); @@ -416,7 +417,7 @@ function testAddDocumentation() public function testAddDocumentationToSetInsertsBefore() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $messageParts = array(); $messageParts['parameter1'] = $wsdl->getType('int'); @@ -448,7 +449,7 @@ public function testAddDocumentationToSetInsertsBefore() function testToXml() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . @@ -463,7 +464,7 @@ function testToXml() function testToDomDocument() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $dom = $wsdl->toDomDocument(); $this->assertTrue($dom instanceOf \DOMDocument); @@ -481,7 +482,7 @@ function testToDomDocument() function testDump() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); ob_start(); $wsdl->dump(); @@ -515,7 +516,7 @@ function testDump() function testGetType() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', true); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', true); $this->assertEquals('xsd:string', $wsdl->getType('string'), 'xsd:string detection failed.'); $this->assertEquals('xsd:string', $wsdl->getType('str'), 'xsd:string detection failed.'); @@ -533,22 +534,22 @@ function testGetType() function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', true); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', true); $this->assertEquals('tns:ZendTest_Soap_TestAsset_WSDLTestClass', $wsdl->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', false); + $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', false); $this->assertEquals('xsd:anyType', $wsdl2->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } function testGetComplexTypeBasedOnStrategiesStringNames() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\DefaultComplexType'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\DefaultComplexType'); $this->assertEquals('tns:ZendTest_Soap_TestAsset_WSDLTestClass', $wsdl->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\AnyType'); + $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\AnyType'); $this->assertEquals('xsd:anyType', $wsdl2->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } @@ -560,10 +561,10 @@ function testSettingUnknownStrategyThrowsException() { set_error_handler(array($this, 'swallowIncludeNotices'), E_WARNING); try { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_UnknownStrategyType'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_UnknownStrategyType'); restore_error_handler(); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } restore_error_handler(); } @@ -572,9 +573,9 @@ function testSettingInvalidStrategyObjectThrowsException() { try { $strategy = new \ZendTest_Soap_TestAsset_WSDLTestClass(); - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php', $strategy); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', $strategy); $this->fail(); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { } } @@ -582,20 +583,20 @@ function testSettingInvalidStrategyObjectThrowsException() function testAddingSameComplexTypeMoreThanOnceIsIgnored() { try { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addType('ZendTest_Soap_TestAsset_WSDLTestClass'); $wsdl->addType('ZendTest_Soap_TestAsset_WSDLTestClass'); $types = $wsdl->getTypes(); $this->assertEquals(1, count($types)); $this->assertEquals(array("ZendTest_Soap_TestAsset_WSDLTestClass"), $types); - } catch(WSDL\Exception $e) { + } catch(WSDLException $e) { $this->fail(); } } function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); $this->assertEquals(array('ZendTest_Soap_TestAsset_WSDLTestClass'), $wsdl->getTypes()); @@ -605,7 +606,7 @@ function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() function testAddComplexType() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); @@ -636,7 +637,7 @@ function testAddComplexType() */ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() { - $wsdl = new WSDL\WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:string", $wsdl->getType("StrIng")); $this->assertEquals("xsd:string", $wsdl->getType("sTr")); @@ -651,7 +652,7 @@ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() */ public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceBySequenceStrategy() { - $wsdl = new WSDL\WSDL("MyService", "http://localhost/MyService.php"); + $wsdl = new WSDL("MyService", "http://localhost/MyService.php"); $wsdl->setComplexTypeStrategy(new Strategy\ArrayOfTypeSequence()); $wsdl->addComplexType("string[]"); @@ -671,7 +672,7 @@ public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceByS */ public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() { - $wsdl = new WSDL\WSDL("MyService", self::URI_WITH_EXPANDED_AMP); + $wsdl = new WSDL("MyService", self::URI_WITH_EXPANDED_AMP); $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } @@ -680,7 +681,7 @@ public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() */ public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly() { - $wsdl = new WSDL\WSDL("MyService", "http://example.com"); + $wsdl = new WSDL("MyService", "http://example.com"); $wsdl->setUri(self::URI_WITH_EXPANDED_AMP); $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } From eaa7fc89fb56a7a6371e0af3e32d31ccaf8864df Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 6 Jul 2010 09:04:48 -0400 Subject: [PATCH 047/123] Zend\Server cleanup - Renamed Reflection\Reflection to Reflection - Updated all dependent code and tests --- src/AutoDiscover.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 8f87ce06..89258e39 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -33,7 +33,7 @@ * * @uses \Zend\Server\AbstractServer * @uses \Zend\Server\Server - * @uses \Zend\Server\Reflection\Reflection + * @uses \Zend\Server\Reflection * @uses \Zend\Soap\AutoDiscover\Exception * @uses \Zend\Soap\WSDL * @uses \Zend\URI\URI @@ -49,7 +49,7 @@ class AutoDiscover implements \Zend\Server\Server protected $_wsdl = null; /** - * @var \Zend\Server\Reflection\Reflection + * @var \Zend\Server\Reflection */ protected $_reflection = null; @@ -100,7 +100,7 @@ class AutoDiscover implements \Zend\Server\Server */ public function __construct($strategy = true, $uri=null, $wsdlClass=null) { - $this->_reflection = new \Zend\Server\Reflection\Reflection(); + $this->_reflection = new \Zend\Server\Reflection(); $this->setComplexTypeStrategy($strategy); if($uri !== null) { From fd861cdfa7f260dc2f54b684de8385a027c0df10 Mon Sep 17 00:00:00 2001 From: rquadling Date: Wed, 14 Jul 2010 15:07:08 +0000 Subject: [PATCH 048/123] Provide support for nillable types in a WSDL file. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22560 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/DefaultComplexType.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index ba7d1a16..183943ea 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -55,6 +55,8 @@ public function addComplexType($type) $dom = $this->getContext()->toDomDocument(); $class = new ReflectionClass($type); + $defaultProperties = $class->getDefaultProperties(); + $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $type); @@ -68,8 +70,14 @@ public function addComplexType($type) * node for describing other classes used as attribute types for current class */ $element = $dom->createElement('xsd:element'); - $element->setAttribute('name', $property->getName()); + $element->setAttribute('name', $propertyName = $property->getName()); $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); + + // If the default value is null, then this property is nillable. + if (is_null($defaultProperties[$propertyName])) { + $element->setAttribute('nillable', 'true'); + } + $all->appendChild($element); } } From daf8aa563ec1bcb0a80c4bfd297a10f59f092b87 Mon Sep 17 00:00:00 2001 From: Alexander Veremyev Date: Tue, 20 Jul 2010 17:58:16 +0400 Subject: [PATCH 049/123] Zend_Soap: support namespaces for SOAP types. --- src/AutoDiscover.php | 32 +-- src/WSDL.php | 21 +- src/WSDL/Strategy/ArrayOfTypeComplex.php | 16 +- src/WSDL/Strategy/Composite.php | 2 +- src/WSDL/Strategy/DefaultComplexType.php | 7 +- test/AutoDiscoverTest.php | 208 +++++++++---------- test/ClientTest.php | 37 ++-- test/ServerTest.php | 96 ++++----- test/TestAsset/WSDLTestClass.php | 4 +- test/TestAsset/commontypes.php | 80 +++---- test/TestAsset/wsdl_documentation.wsdl | 10 +- test/TestAsset/wsdl_example.wsdl | 2 +- test/WSDL/ArrayOfTypeComplexStrategyTest.php | 66 +++--- test/WSDLTest.php | 34 +-- 14 files changed, 317 insertions(+), 298 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 89258e39..380ce851 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -300,16 +300,20 @@ public function setClass($class, $namespace = '', $argv = null) { $uri = $this->getUri(); - $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy); + $translatedClass = WSDL::translateType($class); + + $wsdl = new $this->_wsdlClass($translatedClass, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); - $port = $wsdl->addPortType($class . 'Port'); - $binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port'); + $port = $wsdl->addPortType($translatedClass . 'Port'); + $binding = $wsdl->addBinding($translatedClass . 'Binding', 'tns:' . $translatedClass . 'Port'); $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); - $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri); + $wsdl->addService($translatedClass . 'Service', + $translatedClass . 'Port', + 'tns:' . $translatedClass . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); } @@ -385,6 +389,8 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) throw new AutoDiscoverException("No prototypes could be found for the '" . $function->getName() . "' function"); } + $functionName = WSDL::translateType($function->getName()); + // Add the input message (parameters) $args = array(); if ($this->_bindingStyle['style'] == 'document') { @@ -401,7 +407,7 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) $sequence[] = $sequenceElement; } $element = array( - 'name' => $function->getName(), + 'name' => $functionName, 'sequence' => $sequence ); // Add the wrapper element part, which must be named 'parameters' @@ -412,7 +418,7 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) $args[$param->getName()] = array('type' => $wsdl->getType($param->getType())); } } - $wsdl->addMessage($function->getName() . 'In', $args); + $wsdl->addMessage($functionName . 'In', $args); $isOneWayMessage = false; if($prototype->getReturnType() == "void") { @@ -427,12 +433,12 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) $sequence = array(); if ($prototype->getReturnType() != "void") { $sequence[] = array( - 'name' => $function->getName() . 'Result', + 'name' => $functionName . 'Result', 'type' => $wsdl->getType($prototype->getReturnType()) ); } $element = array( - 'name' => $function->getName() . 'Response', + 'name' => $functionName . 'Response', 'sequence' => $sequence ); // Add the wrapper element part, which must be named 'parameters' @@ -441,14 +447,14 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) // RPC style: add the return value as a typed part $args['return'] = array('type' => $wsdl->getType($prototype->getReturnType())); } - $wsdl->addMessage($function->getName() . 'Out', $args); + $wsdl->addMessage($functionName . 'Out', $args); } // Add the portType operation if($isOneWayMessage == false) { - $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', 'tns:' . $function->getName() . 'Out'); + $portOperation = $wsdl->addPortOperation($port, $functionName, 'tns:' . $functionName . 'In', 'tns:' . $functionName . 'Out'); } else { - $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', false); + $portOperation = $wsdl->addPortOperation($port, $functionName, 'tns:' . $functionName . 'In', false); } $desc = $function->getDescription(); if (strlen($desc) > 0) { @@ -461,8 +467,8 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) } // Add the binding operation - $operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle); - $wsdl->addSoapOperation($operation, $uri . '#' .$function->getName()); + $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle, $this->_operationBodyStyle); + $wsdl->addSoapOperation($operation, $uri . '#' . $functionName); // Add the function name to the list $this->_functions[] = $function->getName(); diff --git a/src/WSDL.php b/src/WSDL.php index 9ee79755..a8fa6d32 100644 --- a/src/WSDL.php +++ b/src/WSDL.php @@ -91,7 +91,7 @@ public function __construct($name, $uri, $strategy = true) $this->_uri = $uri; /** - * @todo change DomDocument object creation from cparsing to construxting using API + * @todo change DomDocument object creation from cparsing to constructing using API * It also should authomatically escape $name and $uri values if necessary */ $wsdl = " @@ -161,7 +161,7 @@ public function setComplexTypeStrategy($strategy) } if(!($strategy instanceof WSDL\Strategy)) { - throw new WSDLException("Set a strategy that is not of type 'Zend\Soap\WSDL\Strategy'"); + throw new WSDLException('Set a strategy that is not of type \'Zend\Soap\WSDL\Strategy\''); } $this->_strategy = $strategy; return $this; @@ -585,6 +585,21 @@ public function addSchemaTypeSection() return $this; } + /** + * Translate PHP type into WSDL QName + * + * @param string $type + * @return string QName + */ + public static function translateType($type) + { + if ($type[0] == '\\') { + $type = substr($type, 1); + } + + return str_replace('\\', '.', $type); + } + /** * Add a {@link http://www.w3.org/TR/wsdl#_types types} data type definition * @@ -594,7 +609,7 @@ public function addSchemaTypeSection() public function addComplexType($type) { if (in_array($type, $this->getTypes())) { - return "tns:$type"; + return 'tns:' . self::translateType($type); } $this->addSchemaTypeSection(); diff --git a/src/WSDL/Strategy/ArrayOfTypeComplex.php b/src/WSDL/Strategy/ArrayOfTypeComplex.php index b3276cad..f09dce89 100644 --- a/src/WSDL/Strategy/ArrayOfTypeComplex.php +++ b/src/WSDL/Strategy/ArrayOfTypeComplex.php @@ -25,10 +25,13 @@ */ namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap; + +use Zend\Soap\WSDL; use Zend\Soap\WSDLException; /** - * Zend_Soap_WSDL_Strategy_ArrayOfTypeComplex + * ArrayOfTypeComplex strategy * * @uses \Zend\Soap\WSDL\Exception * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType @@ -50,7 +53,7 @@ class ArrayOfTypeComplex extends DefaultComplexType */ public function addComplexType($type) { - if(in_array($type, $this->_inProcess)) { + if(isset($this->_inProcess[$type])) { throw new WSDLException("Infinite recursion, cannot nest '$type' into itself."); } $this->_inProcess[$type] = $type; @@ -95,7 +98,7 @@ protected function _addArrayOfComplexType($singularType, $type) $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType); - if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) { + if(!in_array($singularType . '[]', $this->getContext()->getTypes())) { $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $xsdComplexTypeName); @@ -108,11 +111,12 @@ protected function _addArrayOfComplexType($singularType, $type) $xsdAttribute = $dom->createElement('xsd:attribute'); $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType'); - $xsdAttribute->setAttribute('wsdl:arrayType', sprintf('tns:%s[]', $singularType)); + $xsdAttribute->setAttribute('wsdl:arrayType', + 'tns:' . WSDL::translateType($singularType) . '[]'); $xsdRestriction->appendChild($xsdAttribute); $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($xsdComplexTypeName); + $this->getContext()->addType($singularType . '[]'); } return $xsdComplexTypeName; @@ -120,7 +124,7 @@ protected function _addArrayOfComplexType($singularType, $type) protected function _getXsdComplexTypeName($type) { - return sprintf('ArrayOf%s', $type); + return 'ArrayOf' . WSDL::translateType($type); } /** diff --git a/src/WSDL/Strategy/Composite.php b/src/WSDL/Strategy/Composite.php index e2141ed5..53008cdc 100644 --- a/src/WSDL/Strategy/Composite.php +++ b/src/WSDL/Strategy/Composite.php @@ -70,7 +70,7 @@ class Composite implements Strategy * @param array $typeMap * @param string|\Zend\Soap\WSDL\Strategy $defaultStrategy */ - public function __construct(array $typeMap=array(), $defaultStrategy="Zend\Soap\WSDL\Strategy\DefaultComplexType") + public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap\WSDL\Strategy\DefaultComplexType') { foreach($typeMap AS $type => $strategy) { $this->connectTypeToStrategy($type, $strategy); diff --git a/src/WSDL/Strategy/DefaultComplexType.php b/src/WSDL/Strategy/DefaultComplexType.php index 0a9dd642..8092f130 100644 --- a/src/WSDL/Strategy/DefaultComplexType.php +++ b/src/WSDL/Strategy/DefaultComplexType.php @@ -25,6 +25,8 @@ */ namespace Zend\Soap\WSDL\Strategy; +use Zend\Soap; + use Zend\Soap\WSDLException; /** @@ -59,8 +61,9 @@ public function addComplexType($type) $dom = $this->getContext()->toDomDocument(); $class = new \ReflectionClass($type); + $translatedType = Soap\WSDL::translateType($type); $complexType = $dom->createElement('xsd:complexType'); - $complexType->setAttribute('name', $type); + $complexType->setAttribute('name', $translatedType); $all = $dom->createElement('xsd:all'); @@ -82,6 +85,6 @@ public function addComplexType($type) $this->getContext()->getSchema()->appendChild($complexType); $this->getContext()->addType($type); - return "tns:$type"; + return 'tns:' . $translatedType; } } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 6cc3b468..6799ea3d 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -70,7 +70,7 @@ function testSetClass() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(); - $server->setClass('ZendTest_Soap_TestAsset_Test'); + $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -83,12 +83,12 @@ function testSetClass() . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' - . 'name="ZendTest_Soap_TestAsset_Test" ' + . 'name="ZendTest.Soap.TestAsset.Test" ' . 'targetNamespace="' . $scriptUri . '">' . '' . '' . '' - . '' + . '' . '' . 'Test Function 1' . '' @@ -109,7 +109,7 @@ function testSetClass() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -132,8 +132,8 @@ function testSetClass() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -161,7 +161,7 @@ function testSetClassWithDifferentStyles() $server = new AutoDiscover(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); - $server->setClass('ZendTest_Soap_TestAsset_Test'); + $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -174,7 +174,7 @@ function testSetClassWithDifferentStyles() . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' - . 'name="ZendTest_Soap_TestAsset_Test" ' + . 'name="ZendTest.Soap.TestAsset.Test" ' . 'targetNamespace="' . $scriptUri . '">' . '' . '' @@ -229,7 +229,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . 'Test Function 1' . '' @@ -250,7 +250,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -273,8 +273,8 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -319,7 +319,7 @@ function testSetClassWithResponseReturnPartCompabilityMode() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(); - $server->setClass('ZendTest_Soap_TestAsset_Test'); + $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -340,7 +340,7 @@ function testAddFunctionSimple() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -354,12 +354,12 @@ function testAddFunctionSimple() ''. ''. ''. - 'Test Function'. + 'Test Function'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -369,8 +369,8 @@ function testAddFunctionSimple() ''. ''. ''. - ''. - ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -385,7 +385,7 @@ function testAddFunctionSimpleWithDifferentStyle() $server = new AutoDiscover(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -399,17 +399,17 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - 'Test Function'. + 'Test Function'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -419,8 +419,8 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''. - ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -436,7 +436,7 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); $server->handle(); @@ -447,8 +447,8 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $name = $parts[0]; $wsdl = $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()); - $this->assertContains('', $wsdl); - $this->assertNotContains('assertContains('', $wsdl); + $this->assertNotContains('assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(__DIR__.'/TestAsset/addfunction.wsdl'); @@ -459,14 +459,14 @@ function testAddFunctionMultiple() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc2'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc3'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc4'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc5'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc6'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc7'); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc9'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc2'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc3'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc4'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc5'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc6'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc7'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc9'); $dom = new \DOMDocument(); ob_start(); @@ -481,54 +481,54 @@ function testAddFunctionMultiple() ''. ''. ''. - 'Test Function'. - 'Test Function 2'. - 'Return false'. - 'Return true'. - 'Return integer'. - 'Return string'. - 'Return array'. - 'Multiple Args'. + 'Test Function'. + 'Test Function 2'. + 'Return false'. + 'Return true'. + 'Return integer'. + 'Return string'. + 'Return array'. + 'Multiple Args'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -538,21 +538,21 @@ function testAddFunctionMultiple() ''. ''. ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -571,7 +571,7 @@ public function testUseHttpsSchemaIfAccessedThroughHttps() $httpsScriptUri = 'https://localhost/my_script.php'; $server = new AutoDiscover(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); $server->handle(); @@ -588,7 +588,7 @@ public function testChangeWSDLUriInConstructor() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(true, "http://example.com/service.php"); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); $server->handle(); @@ -607,7 +607,7 @@ public function testChangeWSDLUriViaSetUri() $server = new AutoDiscover(true); $server->setUri("http://example.com/service.php"); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); $server->handle(); @@ -637,7 +637,7 @@ public function testChangingWSDLUriAfterGenerationIsPossible() $server = new AutoDiscover(true); $server->setUri("http://example.com/service.php"); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); $server->handle(); @@ -667,7 +667,7 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWSDL() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(); - $server->setClass('ZendTest_Soap_TestAsset_TestFixingMultiplePrototypes'); + $server->setClass('\ZendTest\Soap\TestAsset\TestFixingMultiplePrototypes'); ob_start(); $server->handle(); @@ -705,12 +705,12 @@ public function testUnusedFunctionsOfAutoDiscoverThrowException() public function testGetFunctions() { $server = new AutoDiscover(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); - $server->setClass('ZendTest_Soap_TestAsset_Test'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); + $server->setClass('\ZendTest\Soap\TestAsset\Test'); $functions = $server->getFunctions(); $this->assertEquals( - array('ZendTest_Soap_TestAsset_TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'), + array('ZendTest\Soap\TestAsset\TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'), $functions ); } @@ -755,27 +755,27 @@ public function testUsingRequestUriWithoutParametersAsDefault() public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() { $server = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); - $server->setClass('ZendTest_Soap_TestAsset_AutoDiscoverTestClass2'); + $server->setClass('\ZendTest\Soap\TestAsset\AutoDiscoverTestClass2'); ob_start(); $server->handle(); $wsdlOutput = ob_get_clean(); $this->assertEquals(1, - substr_count($wsdlOutput, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_AutoDiscoverTestClass1[]"'), + substr_count($wsdlOutput, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.AutoDiscoverTestClass1[]"'), 'wsdl:arrayType definition of TestClass1 has to occour once.' ); $this->assertEquals(1, - substr_count($wsdlOutput, ''), - 'Zend_Soap_AutoDiscoverTestClass1 has to be defined once.' + substr_count($wsdlOutput, ''), + '\ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 has to be defined once.' ); $this->assertEquals(1, - substr_count($wsdlOutput, ''), - 'ArrayOfZend_Soap_AutoDiscoverTestClass1 should be defined once.' + substr_count($wsdlOutput, ''), + '\ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 should be defined once.' ); $this->assertTrue( - substr_count($wsdlOutput, '') >= 1, - 'Zend_Soap_AutoDiscoverTestClass1 appears once or more than once in the message parts section.' + substr_count($wsdlOutput, '') >= 1, + '\ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 appears once or more than once in the message parts section.' ); } @@ -785,7 +785,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() public function testDumpOrXmlOfAutoDiscover() { $server = new AutoDiscover(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); $server->handle(); @@ -833,10 +833,10 @@ public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWSDL() public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex() { $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); - $autodiscover->setClass('ZendTest_Soap_TestAsset_MyService'); + $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyService'); $wsdl = $autodiscover->toXml(); - $this->assertEquals(1, substr_count($wsdl, '')); + $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(0, substr_count($wsdl, 'tns:My_Response[]')); } @@ -847,7 +847,7 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayC public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence() { $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence'); - $autodiscover->setClass('ZendTest_Soap_TestAsset_MyServiceSequence'); + $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyServiceSequence'); $wsdl = $autodiscover->toXml(); $this->assertEquals(1, substr_count($wsdl, '')); @@ -865,7 +865,7 @@ public function testAmpersandInUrlIsCorrectlyEncoded() $autodiscover = new AutoDiscover(); $autodiscover->setUri("http://example.com/?a=b&b=c"); - $autodiscover->setClass("ZendTest_Soap_TestAsset_Test"); + $autodiscover->setClass("\ZendTest\Soap\TestAsset\Test"); $wsdl = $autodiscover->toXml(); $this->assertContains("http://example.com/?a=b&b=c", $wsdl); @@ -877,7 +877,7 @@ public function testAmpersandInUrlIsCorrectlyEncoded() public function testNoReturnIsOneWayCallInSetClass() { $autodiscover = new AutoDiscover(); - $autodiscover->setClass('ZendTest_Soap_TestAsset_NoReturnType'); + $autodiscover->setClass('\ZendTest\Soap\TestAsset\NoReturnType'); $wsdl = $autodiscover->toXml(); $this->assertContains( @@ -892,11 +892,11 @@ public function testNoReturnIsOneWayCallInSetClass() public function testNoReturnIsOneWayCallInAddFunction() { $autodiscover = new AutoDiscover(); - $autodiscover->addFunction('ZendTest_Soap_TestAsset_OneWay'); + $autodiscover->addFunction('\ZendTest\Soap\TestAsset\OneWay'); $wsdl = $autodiscover->toXml(); $this->assertContains( - '@param string $message', + '@param string $message', $wsdl ); } @@ -907,8 +907,8 @@ public function testNoReturnIsOneWayCallInAddFunction() */ public function testRecursiveWsdlDependencies() { - $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); - $autodiscover->setClass('Zend_Soap_AutoDiscover_Recursion'); + $autodiscover = new AutoDiscover('\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $autodiscover->setClass('\ZendTest\Soap\TestAsset\Recursion'); $wsdl = $autodiscover->toXml(); // @@ -918,7 +918,7 @@ public function testRecursiveWsdlDependencies() // - $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="Zend_Soap_AutoDiscover_Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:Zend_Soap_AutoDiscover_Recursion"]'; + $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="ZendTest.Soap.TestAsset.Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:ZendTest.Soap.TestAsset.Recursion"]'; $this->assertWsdlPathExists($wsdl, $path); } diff --git a/test/ClientTest.php b/test/ClientTest.php index 92b51924..6c1309de 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -40,17 +40,6 @@ */ class ClientTest extends \PHPUnit_Framework_TestCase { - /** - * Runs this test suite - * - * @return void - */ - public static function main() - { - $suite = new \PHPUnit_Framework_TestSuite(__CLASS__); - $result = \PHPUnit_TextUI_TestRunner::run($suite); - } - public function setUp() { if (!extension_loaded('soap')) { @@ -70,8 +59,8 @@ public function testSetOptions() $ctx = stream_context_create(); $nonWSDLOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), + 'classmap' => array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -108,8 +97,8 @@ public function testSetOptions() $wsdlOptions = array('soap_version' => SOAP_1_1, 'wsdl' => __DIR__.'/TestAsset/wsdl_example.wsdl', - 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), + 'classmap' => array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2',), 'encoding' => 'ISO-8859-1', 'login' => 'http_login', @@ -140,8 +129,8 @@ public function testGetOptions() $options = array('soap_version' => SOAP_1_1, 'wsdl' => __DIR__.'/TestAsset/wsdl_example.wsdl', - 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), + 'classmap' => array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -219,7 +208,7 @@ public function testUserAgentAllowsEmptyString() public function testGetFunctions() { $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); - $server->setClass('ZendTest_Soap_TestAsset_TestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -248,7 +237,7 @@ public function testGetLastRequest() } $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); - $server->setClass('ZendTest_Soap_TestAsset_TestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -278,7 +267,7 @@ public function testGetLastResponse() } $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); - $server->setClass('ZendTest_Soap_TestAsset_TestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -309,7 +298,7 @@ public function testCallInvoke() } $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); - $server->setClass('ZendTest_Soap_TestAsset_TestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); @@ -321,8 +310,8 @@ public function testSetOptionsWithZendConfig() $ctx = stream_context_create(); $nonWSDLOptions = array('soap_version' => SOAP_1_1, - 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), + 'classmap' => array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'location' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -360,7 +349,7 @@ public function testSetInputHeaders() } $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); - $server->setClass('ZendTest_Soap_TestAsset_TestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\TestClass'); $client = new Client\Local($server, __DIR__ . '/TestAsset/wsdl_example.wsdl'); diff --git a/test/ServerTest.php b/test/ServerTest.php index d2998bb2..49a50463 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -59,8 +59,8 @@ public function testSetOptions() $options = array('soap_version' => SOAP_1_1, 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), + 'classmap' => array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' ); @@ -75,8 +75,8 @@ public function testSetOptionsViaSecondConstructorArgument() 'soap_version' => SOAP_1_1, 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', 'classmap' => array( - 'TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2', + 'TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2', ), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', @@ -94,7 +94,7 @@ public function testSetOptionsWithFeaturesOption() $server = new Server(null, array( 'features' => SOAP_SINGLE_ELEMENT_ARRAYS )); - + $this->assertEquals( SOAP_SINGLE_ELEMENT_ARRAYS, $server->getSoapFeatures() @@ -221,8 +221,8 @@ public function testSetClassmap() { $server = new Server(); - $classmap = array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2'); + $classmap = array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2'); $this->assertNull($server->getClassmap()); $server->setClassmap($classmap); @@ -245,8 +245,8 @@ public function testGetClassmap() { $server = new Server(); - $classmap = array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2'); + $classmap = array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2'); $this->assertNull($server->getClassmap()); $server->setClassmap($classmap); @@ -282,16 +282,16 @@ public function testAddFunction() $server = new Server(); // Correct function should pass - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); // Array of correct functions should pass - $functions = array('ZendTest_Soap_TestAsset_TestFunc2', - 'ZendTest_Soap_TestAsset_TestFunc3', - 'ZendTest_Soap_TestAsset_TestFunc4'); + $functions = array('\ZendTest\Soap\TestAsset\TestFunc2', + '\ZendTest\Soap\TestAsset\TestFunc3', + '\ZendTest\Soap\TestAsset\TestFunc4'); $server->addFunction($functions); $this->assertEquals( - array_merge(array('ZendTest_Soap_TestAsset_TestFunc'), $functions), + array_merge(array('\ZendTest\Soap\TestAsset\TestFunc'), $functions), $server->getFunctions() ); } @@ -324,9 +324,9 @@ public function testAddBogusFunctionsAsArray() $server = new Server(); try { - $functions = array('ZendTest_Soap_TestAsset_TestFunc5', + $functions = array('\ZendTest\Soap\TestAsset\TestFunc5', 'bogus_function', - 'ZendTest_Soap_TestAsset_TestFunc6'); + '\ZendTest\Soap\TestAsset\TestFunc6'); $server->addFunction($functions); $this->fail('Invalid function within a set of functions should fail'); } catch (ServerException $e) { @@ -350,7 +350,7 @@ public function testSetClass() // Correct class name should pass try { - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); } catch(\Exception $e) { $this->fail("Setting a correct class name should not fail setClass()"); } @@ -362,8 +362,8 @@ public function testSetClassTwiceThrowsException() // Correct class name should pass try { - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); $this->fail(); } catch(ServerException $e) { $this->assertEquals('A class has already been registered with this soap server instance', $e->getMessage()); @@ -376,7 +376,7 @@ public function testSetClassWithArguments() // Correct class name should pass try { - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass', 1, 2, 3, 4); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass', 1, 2, 3, 4); } catch(\Exception $e) { $this->fail("Setting a correct class name should not fail setClass()"); } @@ -429,10 +429,10 @@ public function testSetObject() } // Correct class name should pass - $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); + $server->setObject(new TestAsset\ServerTestClass()); try { - $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); + $server->setObject(new TestAsset\ServerTestClass()); $this->fail('setClass() should pass only once'); } catch (\Exception $e) { // success @@ -443,25 +443,25 @@ public function testGetFunctions() { $server = new Server(); - $server->addFunction('ZendTest_Soap_TestAsset_TestFunc'); + $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - $functions = array('ZendTest_Soap_TestAsset_TestFunc2', - 'ZendTest_Soap_TestAsset_TestFunc3', - 'ZendTest_Soap_TestAsset_TestFunc4'); + $functions = array('\ZendTest\Soap\TestAsset\TestFunc2', + '\ZendTest\Soap\TestAsset\TestFunc3', + '\ZendTest\Soap\TestAsset\TestFunc4'); $server->addFunction($functions); - $functions = array('ZendTest_Soap_TestAsset_TestFunc3', - 'ZendTest_Soap_TestAsset_TestFunc5', - 'ZendTest_Soap_TestAsset_TestFunc6'); + $functions = array('\ZendTest\Soap\TestAsset\TestFunc3', + '\ZendTest\Soap\TestAsset\TestFunc5', + '\ZendTest\Soap\TestAsset\TestFunc6'); $server->addFunction($functions); $allAddedFunctions = array( - 'ZendTest_Soap_TestAsset_TestFunc', - 'ZendTest_Soap_TestAsset_TestFunc2', - 'ZendTest_Soap_TestAsset_TestFunc3', - 'ZendTest_Soap_TestAsset_TestFunc4', - 'ZendTest_Soap_TestAsset_TestFunc5', - 'ZendTest_Soap_TestAsset_TestFunc6' + '\ZendTest\Soap\TestAsset\TestFunc', + '\ZendTest\Soap\TestAsset\TestFunc2', + '\ZendTest\Soap\TestAsset\TestFunc3', + '\ZendTest\Soap\TestAsset\TestFunc4', + '\ZendTest\Soap\TestAsset\TestFunc5', + '\ZendTest\Soap\TestAsset\TestFunc6' ); $this->assertTrue($server->getFunctions() == $allAddedFunctions); } @@ -469,7 +469,7 @@ public function testGetFunctions() public function testGetFunctionsWithClassAttached() { $server = new Server(); - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); $this->assertEquals( array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), @@ -480,7 +480,7 @@ public function testGetFunctionsWithClassAttached() public function testGetFunctionsWithObjectAttached() { $server = new Server(); - $server->setObject(new \ZendTest_Soap_TestAsset_ServerTestClass()); + $server->setObject(new TestAsset\ServerTestClass()); $this->assertEquals( array('testFunc1', 'testFunc2', 'testFunc3', 'testFunc4', 'testFunc5'), @@ -538,7 +538,7 @@ public function testGetLastRequest() $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); $request = '' . "\n" @@ -594,7 +594,7 @@ public function testGetLastResponse() $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); $server->setReturnResponse(true); - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); $request = '' . "\n" @@ -645,12 +645,12 @@ public function testHandle() $server = new Server(); $server->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); - $localClient = new \ZendTest_Soap_TestAsset_TestLocalSoapClient($server, - null, - array('location'=>'test://', - 'uri'=>'http://framework.zend.com')); + $localClient = new TestAsset\TestLocalSoapClient($server, + null, + array('location'=>'test://', + 'uri'=>'http://framework.zend.com')); // Local SOAP client call automatically invokes handle method of the provided SOAP server $this->assertEquals('Hello World!', $localClient->testFunc2('World')); @@ -689,7 +689,7 @@ public function testHandle() $server1 = new Server(); $server1->setOptions(array('location'=>'test://', 'uri'=>'http://framework.zend.com')); - $server1->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server1->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); $server1->setReturnResponse(true); $this->assertEquals($expectedResponse, $server1->handle($request)); @@ -842,7 +842,7 @@ public function testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHan . '' . '' . "\n"; - $server->setClass('ZendTest_Soap_TestAsset_ServerTestClass'); + $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); $response = $server->handle($request); $this->assertContains( @@ -858,8 +858,8 @@ public function testServerAcceptsZendConfigObject() { $options = array('soap_version' => SOAP_1_1, 'actor' => 'http://framework.zend.com/Zend_Soap_ServerTest.php', - 'classmap' => array('TestData1' => 'ZendTest_Soap_TestAsset_TestData1', - 'TestData2' => 'ZendTest_Soap_TestAsset_TestData2',), + 'classmap' => array('TestData1' => '\ZendTest\Soap\TestAsset\TestData1', + 'TestData2' => '\ZendTest\Soap\TestAsset\TestData2',), 'encoding' => 'ISO-8859-1', 'uri' => 'http://framework.zend.com/Zend_Soap_ServerTest.php' ); diff --git a/test/TestAsset/WSDLTestClass.php b/test/TestAsset/WSDLTestClass.php index 440eb893..ad645b22 100644 --- a/test/TestAsset/WSDLTestClass.php +++ b/test/TestAsset/WSDLTestClass.php @@ -1,9 +1,11 @@ 'bar', 'baz' => true, 1 => false, 'bat' => 123); } @@ -101,7 +101,7 @@ function ZendTest_Soap_TestAsset_TestFunc7() * * @return StdClass */ -function ZendTest_Soap_TestAsset_TestFunc8() +function TestFunc8() { $return = (object) array('foo' => 'bar', 'baz' => true, 'bat' => 123, 'qux' => false); return $return; @@ -114,7 +114,7 @@ function ZendTest_Soap_TestAsset_TestFunc8() * @param string $bar * @return string */ -function ZendTest_Soap_TestAsset_TestFunc9($foo, $bar) +function TestFunc9($foo, $bar) { return "$foo $bar"; } @@ -126,7 +126,7 @@ function ZendTest_Soap_TestAsset_TestFunc9($foo, $bar) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_TestFixingMultiplePrototypes +class TestFixingMultiplePrototypes { /** * Test function @@ -149,7 +149,7 @@ function testFunc($a=100, $b=200, $d=300) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_Test { +class Test { /** * Test Function 1 * @@ -194,7 +194,7 @@ static function testFunc4() } } -class ZendTest_Soap_TestAsset_AutoDiscoverTestClass1 +class AutoDiscoverTestClass1 { /** * @var integer $var @@ -214,11 +214,11 @@ class ZendTest_Soap_TestAsset_AutoDiscoverTestClass1 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_AutoDiscoverTestClass2 +class AutoDiscoverTestClass2 { /** * - * @param ZendTest_Soap_TestAsset_AutoDiscoverTestClass1 $test + * @param \ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 $test * @return boolean */ public function add(AutoDiscoverTestClass1 $test) @@ -227,7 +227,7 @@ public function add(AutoDiscoverTestClass1 $test) } /** - * @return ZendTest_Soap_TestAsset_AutoDiscoverTestClass1[] + * @return \ZendTest\Soap\TestAsset\AutoDiscoverTestClass1[] */ public function fetchAll() { @@ -238,7 +238,7 @@ public function fetchAll() } /** - * @param ZendTest_Soap_TestAsset_AutoDiscoverTestClass1[] + * @param \ZendTest\Soap\TestAsset\AutoDiscoverTestClass1[] */ public function addMultiple($test) { @@ -253,7 +253,7 @@ public function addMultiple($test) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_ComplexTypeB +class ComplexTypeB { /** * @var string @@ -272,10 +272,10 @@ class ZendTest_Soap_TestAsset_ComplexTypeB * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_ComplexTypeA +class ComplexTypeA { /** - * @var ZendTest_Soap_TestAsset_ComplexTypeB[] + * @var \ZendTest\Soap\TestAsset\ComplexTypeB[] */ public $baz = array(); } @@ -287,7 +287,7 @@ class ZendTest_Soap_TestAsset_ComplexTypeA * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_ComplexTest +class ComplexTest { /** * @var int @@ -302,7 +302,7 @@ class ZendTest_Soap_TestAsset_ComplexTest * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_ComplexObjectStructure +class ComplexObjectStructure { /** * @var boolean @@ -332,10 +332,10 @@ class ZendTest_Soap_TestAsset_ComplexObjectStructure * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure +class ComplexObjectWithObjectStructure { /** - * @var ZendTest_Soap_TestAsset_ComplexTest + * @var \ZendTest\Soap\TestAsset\ComplexTest */ public $object; } @@ -347,24 +347,24 @@ class ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_MyService +class MyService { /** * @param string $foo - * @return ZendTest_Soap_TestAsset_MyResponse[] + * @return \ZendTest\Soap\TestAsset\MyResponse[] */ public function foo($foo) { } /** * @param string $bar - * @return ZendTest_Soap_TestAsset_MyResponse[] + * @return \ZendTest\Soap\TestAsset\MyResponse[] */ public function bar($bar) { } /** * @param string $baz - * @return ZendTest_Soap_TestAsset_MyResponse[] + * @return \ZendTest\Soap\TestAsset\MyResponse[] */ public function baz($baz) { } @@ -377,7 +377,7 @@ public function baz($baz) { * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_MyServiceSequence +class MyServiceSequence { /** * @param string $foo @@ -414,7 +414,7 @@ public function bazNested($baz) { * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_MyResponse +class MyResponse { /** * @var string @@ -429,15 +429,15 @@ class ZendTest_Soap_TestAsset_MyResponse * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_Recursion +class Recursion { /** - * @var ZendTest_Soap_TestAsset_Recursion + * @var \ZendTest\Soap\TestAsset\Recursion */ public $recursion; /** - * @return ZendTest_Soap_TestAsset_Recursion + * @return \ZendTest\Soap\TestAsset\Recursion */ public function create() {} } @@ -445,7 +445,7 @@ public function create() {} /** * @param string $message */ -function ZendTest_Soap_TestAsset_OneWay($message) +function OneWay($message) { } @@ -457,7 +457,7 @@ function ZendTest_Soap_TestAsset_OneWay($message) * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class ZendTest_Soap_TestAsset_NoReturnType +class NoReturnType { /** * @@ -471,7 +471,7 @@ public function pushOneWay($message) /* Client test classes */ /** Test Class */ -class ZendTest_Soap_TestAsset_TestClass { +class TestClass { /** * Test Function 1 * @@ -517,7 +517,7 @@ static function testFunc4() } /** Test class 2 */ -class ZendTest_Soap_TestAsset_TestData1 { +class TestData1 { /** * Property1 * @@ -534,7 +534,7 @@ class ZendTest_Soap_TestAsset_TestData1 { } /** Test class 2 */ -class ZendTest_Soap_TestAsset_TestData2 { +class TestData2 { /** * Property1 * @@ -551,7 +551,7 @@ class ZendTest_Soap_TestAsset_TestData2 { } /** Server test classes */ -class ZendTest_Soap_TestAsset_ServerTestClass +class ServerTestClass { /** * Test Function 1 @@ -610,7 +610,7 @@ function testFunc5() if (extension_loaded('soap')) { /** Local SOAP client */ -class ZendTest_Soap_TestAsset_TestLocalSoapClient extends \SoapClient +class TestLocalSoapClient extends \SoapClient { /** * Server object diff --git a/test/TestAsset/wsdl_documentation.wsdl b/test/TestAsset/wsdl_documentation.wsdl index 5538eccd..18870d84 100644 --- a/test/TestAsset/wsdl_documentation.wsdl +++ b/test/TestAsset/wsdl_documentation.wsdl @@ -1,8 +1,8 @@ - + Definitions - + Ports @@ -22,7 +22,7 @@ - + Bindings @@ -69,9 +69,9 @@ - + Services - + diff --git a/test/TestAsset/wsdl_example.wsdl b/test/TestAsset/wsdl_example.wsdl index 907a837c..129f28de 100644 --- a/test/TestAsset/wsdl_example.wsdl +++ b/test/TestAsset/wsdl_example.wsdl @@ -1,2 +1,2 @@ - + diff --git a/test/WSDL/ArrayOfTypeComplexStrategyTest.php b/test/WSDL/ArrayOfTypeComplexStrategyTest.php index e7b551ba..5167f5d3 100644 --- a/test/WSDL/ArrayOfTypeComplexStrategyTest.php +++ b/test/WSDL/ArrayOfTypeComplexStrategyTest.php @@ -53,13 +53,13 @@ public function setUp() public function testNestingObjectsDeepMakesNoSenseThrowingException() { $this->setExpectedException('Zend\Soap\WSDLException'); - $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[][]'); + $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[][]'); } public function testAddComplexTypeOfNonExistingClassThrowsException() { $this->setExpectedException('Zend\Soap\WSDLException'); - $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_UnknownClass[]'); + $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\UnknownClass[]'); } /** @@ -67,27 +67,27 @@ public function testAddComplexTypeOfNonExistingClassThrowsException() */ public function testArrayOfSimpleObject() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[]'); - $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexTest", $return); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[]'); + $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexTest", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } public function testThatOverridingStrategyIsReset() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTest[]'); - $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexTest", $return); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[]'); + $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexTest", $return); // $this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplexStrategy); $wsdl = $this->wsdl->toXML(); @@ -98,43 +98,43 @@ public function testThatOverridingStrategyIsReset() */ public function testArrayOfComplexObjects() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectStructure[]'); - $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexObjectStructure", $return); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectStructure[]'); + $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexObjectStructure", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } public function testArrayOfObjectWithObject() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); - $this->assertEquals("tns:ArrayOfZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure", $return); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectWithObjectStructure[]'); + $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } @@ -144,19 +144,19 @@ public function testArrayOfObjectWithObject() */ public function testAddingTypesMultipleTimesIsSavedOnlyOnce() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectWithObjectStructure[]'); $wsdl = $this->wsdl->toXML(); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]"') + substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure[]"') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); } @@ -165,19 +165,19 @@ public function testAddingTypesMultipleTimesIsSavedOnlyOnce() */ public function testAddingSingularThenArrayTypeIsRecognizedCorretly() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure'); - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectWithObjectStructure'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectWithObjectStructure[]'); $wsdl = $this->wsdl->toXML(); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_ComplexObjectWithObjectStructure[]"') + substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure[]"') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); } @@ -187,7 +187,7 @@ public function testAddingSingularThenArrayTypeIsRecognizedCorretly() public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowingException() { try { - $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_ComplexTypeA"); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTypeA'); $wsdl = $this->wsdl->toXml(); } catch(\Exception $e) { $this->fail("Adding object with nested structure should not throw exception."); @@ -199,19 +199,19 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndNotThrowing */ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllTypesRecursivly() { - $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_ComplexTypeA"); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTypeA'); $wsdl = $this->wsdl->toXml(); $this->assertEquals(1, - substr_count($wsdl, ''), + substr_count($wsdl, ''), 'No definition of complex type A found.' ); $this->assertEquals(1, - substr_count($wsdl, ''), + substr_count($wsdl, ''), 'No definition of complex type B array found.' ); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest_Soap_TestAsset_ComplexTypeB[]"'), + substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.ComplexTypeB[]"'), 'No usage of Complex Type B array found.' ); } @@ -223,6 +223,6 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllType public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() { $this->setExpectedException('Zend\Soap\WSDLException', 'Infinite recursion'); - $return = $this->wsdl->addComplexType("ZendTest_Soap_TestAsset_Recursion"); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\Recursion'); } } diff --git a/test/WSDLTest.php b/test/WSDLTest.php index 6507c3b3..5ee65a8c 100644 --- a/test/WSDLTest.php +++ b/test/WSDLTest.php @@ -535,22 +535,22 @@ function testGetType() function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', true); - $this->assertEquals('tns:ZendTest_Soap_TestAsset_WSDLTestClass', $wsdl->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); + $this->assertEquals('tns:ZendTest.Soap.TestAsset.WSDLTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', false); - $this->assertEquals('xsd:anyType', $wsdl2->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); - $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); +// $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', false); +// $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); +// $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } function testGetComplexTypeBasedOnStrategiesStringNames() { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\DefaultComplexType'); - $this->assertEquals('tns:ZendTest_Soap_TestAsset_WSDLTestClass', $wsdl->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); + $this->assertEquals('tns:ZendTest.Soap.TestAsset.WSDLTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\AnyType'); - $this->assertEquals('xsd:anyType', $wsdl2->getType('ZendTest_Soap_TestAsset_WSDLTestClass')); + $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } @@ -561,7 +561,7 @@ function testSettingUnknownStrategyThrowsException() { set_error_handler(array($this, 'swallowIncludeNotices'), E_WARNING); try { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend_Soap_WSDL_Strategy_UnknownStrategyType'); + $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', '\Zend\Soap\WSDL\Strategy\UnknownStrategyType'); restore_error_handler(); $this->fail(); } catch(WSDLException $e) { @@ -572,7 +572,7 @@ function testSettingUnknownStrategyThrowsException() function testSettingInvalidStrategyObjectThrowsException() { try { - $strategy = new \ZendTest_Soap_TestAsset_WSDLTestClass(); + $strategy = new TestAsset\WSDLTestClass(); $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', $strategy); $this->fail(); } catch(WSDLException $e) { @@ -584,11 +584,11 @@ function testAddingSameComplexTypeMoreThanOnceIsIgnored() { try { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addType('ZendTest_Soap_TestAsset_WSDLTestClass'); - $wsdl->addType('ZendTest_Soap_TestAsset_WSDLTestClass'); + $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass'); + $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass'); $types = $wsdl->getTypes(); $this->assertEquals(1, count($types)); - $this->assertEquals(array("ZendTest_Soap_TestAsset_WSDLTestClass"), $types); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass'), $types); } catch(WSDLException $e) { $this->fail(); } @@ -597,18 +597,18 @@ function testAddingSameComplexTypeMoreThanOnceIsIgnored() function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); - $this->assertEquals(array('ZendTest_Soap_TestAsset_WSDLTestClass'), $wsdl->getTypes()); + $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass'), $wsdl->getTypes()); - $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); - $this->assertEquals(array('ZendTest_Soap_TestAsset_WSDLTestClass'), $wsdl->getTypes()); + $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass'), $wsdl->getTypes()); } function testAddComplexType() { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('ZendTest_Soap_TestAsset_WSDLTestClass'); + $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), '' . @@ -621,7 +621,7 @@ function testAddComplexType() . 'name="MyService" targetNamespace="http://localhost/MyService.php">' . '' . '' - . '' + . '' . '' . '' . '' From e8ca1e99180f3901acaa112e99079fd50a98efe3 Mon Sep 17 00:00:00 2001 From: Alexander Veremyev Date: Tue, 20 Jul 2010 18:14:48 +0400 Subject: [PATCH 050/123] Zend_Soap: remove obsolete tests. --- test/WSDL/ElementTest.php | 245 -------------------------------------- test/WSDL/ParserTest.php | 191 ----------------------------- 2 files changed, 436 deletions(-) delete mode 100644 test/WSDL/ElementTest.php delete mode 100644 test/WSDL/ParserTest.php diff --git a/test/WSDL/ElementTest.php b/test/WSDL/ElementTest.php deleted file mode 100644 index b63bdbaa..00000000 --- a/test/WSDL/ElementTest.php +++ /dev/null @@ -1,245 +0,0 @@ -assertEquals("name1", $binding->getName()); - $this->assertEquals("port1", $binding->portName); - $this->assertEquals($operations, $binding->operations); - $this->assertEquals("test", $binding->getDocumentation()); - - try { - $binding = new WSDL\Element\Binding(array(), "portName", $operations, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testTypeElementApi() - { - $types = new WSDL\Element\Collection("test"); - $type = new WSDL\Element\Type("name1", $types, "test"); - - $this->assertEquals("name1", $type->getName()); - $this->assertEquals($types, $type->types); - $this->assertEquals("test", $type->getDocumentation()); - - try { - $type = new WSDL\Element\Type(array(), $types, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testMessageElementApi() - { - $parts = new WSDL\Element\Collection("test"); - $message = new WSDL\Element\Message("name1", $parts, "test"); - - $this->assertEquals("name1", $message->getName()); - $this->assertEquals($parts, $message->parts); - $this->assertEquals("test", $message->getDocumentation()); - - try { - $message = new WSDL\Element\Message(array(), $parts, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testPortElementApi() - { - $operations = new WSDL\Element\Collection("test"); - $port = new WSDL\Element\Port("name1", $operations, "test"); - - $this->assertEquals("name1", $port->getName()); - $this->assertEquals($operations, $port->operations); - $this->assertEquals("test", $port->getDocumentation()); - - try { - $port = new WSDL\Element\Port(array(), $operations, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testOperationElementApi() - { - $collection = new WSDL\Element\Collection("test"); - $input = new WSDL\Element\Message("name", $collection, "test"); - $output = new WSDL\Element\Message("name", $collection, "test"); - - $operation = new WSDL\Element\Operation("name1", $input, $output, "test"); - - $this->assertEquals("name1", $operation->getName()); - $this->assertEquals($input, $operation->inputMessage); - $this->assertEquals($output, $operation->outputMessage); - $this->assertEquals("test", $operation->getDocumentation()); - - try { - $operation = new WSDL\Element\Operation(array(), $input, $output, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testServiceElementApi() - { - $collection = new WSDL\Element\Collection("test"); - $port = new WSDL\Element\Port("name", $collection, "test"); - $binding = new WSDL\Element\Binding("name", "port", $collection, "test"); - - $service = new WSDL\Element\Service("service", "address", $port, $binding, "test"); - - $this->assertEquals("service", $service->getName()); - $this->assertEquals("address", $service->soapAddress); - $this->assertEquals($port, $service->port); - $this->assertEquals($binding, $service->binding); - $this->assertEquals("test", $service->getDocumentation()); - - try { - $service = new WSDL\Element\Service(array(), "address", $port, $binding, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - - try { - $service = new WSDL\Element\Service("name", array(), $port, $binding, "test"); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testCollectionElementApiConstruct() - { - $collection = new WSDL\Element\Collection("Operation"); - - $this->assertTrue($collection instanceof \Countable); - $this->assertTrue($collection instanceof \Iterator); - - try { - $type = new WSDL\Element\Type("type", new WSDL\Element\Collection("Type"), "test"); - $collection->addElement($type); - $this->fail(); - } catch(WSDLException $e) { - - } - - try { - $collection = new WSDL\Element\Collection(false); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testCollectionElementApiType() - { - $collection = new WSDL\Element\Collection("Operation"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Operation", $collection->getType()); - - $collection = new WSDL\Element\Collection("Type"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Type", $collection->getType()); - - $collection = new WSDL\Element\Collection("Binding"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Binding", $collection->getType()); - - $collection = new WSDL\Element\Collection("Service"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Service", $collection->getType()); - - $collection = new WSDL\Element\Collection("Port"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Port", $collection->getType()); - - $collection = new WSDL\Element\Collection("Message"); - $this->assertEquals("\Zend\Soap\WSDL\Element\Message", $collection->getType()); - } - - public function testCollectionElementApiElementAccess() - { - $collection = new WSDL\Element\Collection("Message"); - $message1 = new WSDL\Element\Message("message1", new WSDL\Element\Collection("Type"), "test"); - $message2 = new WSDL\Element\Message("message2", new WSDL\Element\Collection("Type"), "test"); - $messageDuplicate = new WSDL\Element\Message("message2", new WSDL\Element\Collection("Type"), "test"); - - $collection->addElement($message1); - $this->assertEquals(array("message1"), $collection->getElementNames()); - $this->assertEquals($message1, $collection->getElement("message1")); - $this->assertEquals(1, count($collection)); - - $collection->addElement($message2); - $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); - $this->assertEquals($message2, $collection->getElement("message2")); - $this->assertEquals(2, count($collection)); - - try { - // Adding duplicate message leads to exception - $collection->addElement($messageDuplicate); - $this->fail("Adding a duplicate named element to a collection should throw an exception."); - } catch(WSDLException $e) { - $this->assertEquals(array("message1", "message2"), $collection->getElementNames()); - $this->assertEquals($message2, $collection->getElement("message2")); - $this->assertEquals(2, count($collection)); - } - - try { - // Accessing unkown message leads to exception - $collection->getElement("messageUnknown"); - $this->fail("Accessing unknown element should throw an exception."); - } catch(WSDLException $e) { - $this->assertEquals(2, count($collection)); - } - - foreach($collection AS $name => $message) { - $this->assertTrue($message instanceof WSDL\Element\Message); - $this->assertTrue( in_array($name, $collection->getElementNames()) ); - } - } -} diff --git a/test/WSDL/ParserTest.php b/test/WSDL/ParserTest.php deleted file mode 100644 index 3499913d..00000000 --- a/test/WSDL/ParserTest.php +++ /dev/null @@ -1,191 +0,0 @@ -loadXml(file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl")); - return $dom; - } - - public function testFactoryWithDomDocument() - { - $dom = $this->getWSDLExampleDom(); - $parser = WSDL\Parser::factory($dom); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithString() - { - $xmlString = file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl"); - $parser = WSDL\Parser::factory($xmlString); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithSimpleXml() - { - $xmlString = file_get_contents(__DIR__."/../TestAsset/wsdl_example.wsdl"); - $simpleXml = simplexml_load_string($xmlString); - $parser = WSDL\Parser::factory($simpleXml); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithZendSoapWSDL() - { - $wsdl = new WSDL("name", "http://example.com"); - $parser = WSDL\Parser::factory($wsdl); - $this->assertTrue($parser instanceof WSDL\Parser); - } - - public function testFactoryWithInvalidParser() - { - $wsdl = new WSDL("name", "http://example.com"); - try { - $parser = WSDL\Parser::factory($wsdl, "stdClass"); - $this->fail(); - } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Parser\Exception); - } - } - - public function testFactoryWithInvalidData() - { - try { - $parser = WSDL\Parser::factory(null); - $this->fail(); - } catch(WSDLException $e) { - - } - } - - public function testParserApiInterface() - { - // Constructor expects DOMDocument instance - $dom = $this->getWSDLExampleDom(); - $parser = new WSDL\Parser($dom); - - // SetWSDL is a fluent function - $this->assertTrue( ($parser->setDomDocumentContainingWSDL($dom)) instanceof WSDL\Parser ); - - // Parse returns Result - $result = $parser->parse(); - $this->assertTrue($result instanceof WSDL\Parser\Result); - } - - public function testParserResultApiInterface() - { - $result = new WSDL\Parser\Result( - "name", - WSDL\Parser::WSDL_11, - new WSDL\Element_Collection("Operation"), - new WSDL\Element_Collection("Port"), - new WSDL\Element_Collection("Binding"), - new WSDL\Element_Collection("Service"), - new WSDL\Element_Collection("Type"), - array("docs") - ); - - $this->assertEquals("name", $result->getName()); - $this->assertEquals("Zend_Soap_WSDL_Element_Operation", $result->operations->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Port", $result->ports->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Binding", $result->bindings->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Service", $result->services->getType()); - $this->assertEquals("Zend_Soap_WSDL_Element_Type", $result->types->getType()); - $this->assertEquals(array("docs"), $result->documentation); - - try { - $key = $result->invalidKeyThrowsException; - $this->fail(); - } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDL\Parser\Exception); - } - } - - public function testParseExampleWSDLAndCountResultElements() - { - // Constructor expects DOMDocument instance - $dom = $this->getWSDLExampleDom(); - $parser = new WSDL\Parser($dom); - - $result = $parser->parse(); - - $this->assertEquals("Zend_Soap_Server_TestClass", $result->getName()); - $this->assertEquals(WSDL\Parser::WSDL_11, $result->getVersion()); - $this->assertEquals(4, count($result->operations), "Number of operations does not match."); - $this->assertEquals(1, count($result->bindings), "Number of bindings does not match."); - $this->assertEquals(1, count($result->ports), "Number of ports does not match."); - $this->assertEquals(1, count($result->services), "Number of services does not match."); - $this->assertEquals(0, count($result->types), "Number of types does not match."); - $this->assertEquals(4, count($result->bindings->current()->operations), "Number of operations in the bindings collection does not match."); - $this->assertEquals(4, count($result->ports->current()->operations), "Number of operations in the ports collection does not match."); - } - - public function testParseExampleWSDLAndCheckMatchingNames() - { - // Constructor expects DOMDocument instance - $dom = $this->getWSDLExampleDom(); - $parser = new WSDL\Parser($dom); - - $result = $parser->parse(); - - foreach($result->operations AS $operation) { - $this->assertContains($operation->getName(), array("testFunc1", "testFunc2", "testFunc3", "testFunc4")); - } - foreach($result->bindings AS $binding) { - $this->assertEquals("Zend_Soap_Server_TestClassBinding", $binding->getName()); - } - foreach($result->ports AS $port) { - $this->assertEquals("Zend_Soap_Server_TestClassPort", $port->getName()); - } - foreach($result->services AS $service) { - $this->assertEquals("Zend_Soap_Server_TestClassService", $service->getName()); - } - } - - public function testParseExampleWSDLWithDocumentationBlocks() - { - $dom = new \DOMDocument(); - $dom->loadXml(file_get_contents(__DIR__."/../TestAsset/wsdl_documentation.wsdl")); - - $parser = new WSDL\Parser($dom); - $result = $parser->parse(); - } -} From 20f02af326f61a4a43395a056b7d6e9b78df1b17 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 20 Jul 2010 16:36:47 -0400 Subject: [PATCH 051/123] URI -> Uri; URL -> Url - Renamed all directories and filenames from URI to Uri - Renamed all namespaces and classnames from URI to Uri - Renamed all directories and filenames from URL to Url - Renamed all namespaces and classnames from URL to Url --- src/AutoDiscover.php | 16 ++++++++-------- src/WSDL.php | 2 +- test/AutoDiscoverTest.php | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 89258e39..e0865bf6 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -25,7 +25,7 @@ */ namespace Zend\Soap; -use Zend\URI, +use Zend\Uri, Zend\Soap\WSDL; /** @@ -36,7 +36,7 @@ * @uses \Zend\Server\Reflection * @uses \Zend\Soap\AutoDiscover\Exception * @uses \Zend\Soap\WSDL - * @uses \Zend\URI\URI + * @uses \Zend\Uri\Uri * @category Zend * @package Zend_Soap * @subpackage AutoDiscover @@ -95,7 +95,7 @@ class AutoDiscover implements \Zend\Server\Server * Constructor * * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy - * @param string|\Zend\URI\URI $uri + * @param string|\Zend\Uri\Uri $uri * @param string $wsdlClass */ public function __construct($strategy = true, $uri=null, $wsdlClass=null) @@ -116,14 +116,14 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null) * Set the location at which the WSDL file will be availabe. * * @throws \Zend\Soap\AutoDiscover\Exception - * @param \Zend\URI\URI|string $uri + * @param \Zend\Uri\Uri|string $uri * @return \Zend\Soap\AutoDiscover */ public function setUri($uri) { - if(!is_string($uri) && !($uri instanceof URI\URI)) { + if(!is_string($uri) && !($uri instanceof URI\Uri)) { throw new AutoDiscoverException( - 'No uri given to \Zend\Soap\AutoDiscover::setUri as string or \Zend\URI\URI instance.' + 'No uri given to \Zend\Soap\AutoDiscover::setUri as string or \Zend\Uri\Uri instance.' ); } $this->_uri = $uri; @@ -139,7 +139,7 @@ public function setUri($uri) /** * Return the current Uri that the SOAP WSDL Service will be located at. * - * @return \Zend\URI\URI + * @return \Zend\Uri\Uri */ public function getUri() { @@ -149,7 +149,7 @@ public function getUri() $schema = $this->getSchema(); $host = $this->getHostName(); $scriptName = $this->getRequestUriWithoutParameters(); - $uri = new URI\URL($schema . '://' . $host . $scriptName); + $uri = new Uri\Url($schema . '://' . $host . $scriptName); $this->setUri($uri); } return $uri; diff --git a/src/WSDL.php b/src/WSDL.php index 9ee79755..e9173dbd 100644 --- a/src/WSDL.php +++ b/src/WSDL.php @@ -24,7 +24,7 @@ */ namespace Zend\Soap; -use Zend\URI\URL; +use Zend\Uri\Url; /** * \Zend\Soap\WSDL diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 6cc3b468..9aeacde2 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -907,8 +907,8 @@ public function testNoReturnIsOneWayCallInAddFunction() */ public function testRecursiveWsdlDependencies() { - $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); - $autodiscover->setClass('Zend_Soap_AutoDiscover_Recursion'); + $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $autodiscover->setClass('ZendTest_Soap_TestAsset_Recursion'); $wsdl = $autodiscover->toXml(); // From 8937bcbd42c1a51929e2355a330499ff9b1e86be Mon Sep 17 00:00:00 2001 From: Alexander Veremyev Date: Wed, 21 Jul 2010 00:49:29 +0400 Subject: [PATCH 052/123] Zend\Soap: ArrayOfTypeSequence behavior is updated to support namespaces. --- src/WSDL/Strategy/ArrayOfTypeComplex.php | 2 +- src/WSDL/Strategy/ArrayOfTypeSequence.php | 54 ++++++++----------- test/AutoDiscoverTest.php | 2 + test/WSDL/ArrayOfTypeSequenceStrategyTest.php | 12 ++--- 4 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/WSDL/Strategy/ArrayOfTypeComplex.php b/src/WSDL/Strategy/ArrayOfTypeComplex.php index f09dce89..e8698464 100644 --- a/src/WSDL/Strategy/ArrayOfTypeComplex.php +++ b/src/WSDL/Strategy/ArrayOfTypeComplex.php @@ -80,7 +80,7 @@ public function addComplexType($type) // The following blocks define the Array of Object structure $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type); } else { - $xsdComplexTypeName = $singularType; + $xsdComplexTypeName = WSDL::translateType($singularType); } // The array for the objects has been created, now build the object definition: diff --git a/src/WSDL/Strategy/ArrayOfTypeSequence.php b/src/WSDL/Strategy/ArrayOfTypeSequence.php index dc5806a1..c6c62b5f 100644 --- a/src/WSDL/Strategy/ArrayOfTypeSequence.php +++ b/src/WSDL/Strategy/ArrayOfTypeSequence.php @@ -34,6 +34,8 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ +use Zend\Soap\WSDL; + class ArrayOfTypeSequence extends DefaultComplexType { /** @@ -50,15 +52,19 @@ public function addComplexType($type) $singularType = $this->_getSingularType($type); for($i = 1; $i <= $nestedCounter; $i++) { - $complexTypeName = substr($this->_getTypeNameBasedOnNestingLevel($singularType, $i), 4); - $childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1); + $complexType = $this->_getTypeBasedOnNestingLevel($singularType, $i); + $complexTypeName = substr($complexType, strpos($complexType, ':') + 1); + + $childType = $this->_getTypeBasedOnNestingLevel($singularType, $i-1); - $this->_addElementFromWSDLAndChildTypes($complexTypeName, $childTypeName); + $this->_addSequenceType($complexTypeName, + $childType, + $singularType . str_repeat('[]', $i)); } // adding the PHP type which is resolved to a nested XSD type. therefore add only once. - $this->getContext()->addType($complexTypeName); + $this->getContext()->addType($type); - return "tns:$complexTypeName"; + return 'tns:' . $complexTypeName; } else if (!in_array($type, $this->getContext()->getTypes())) { // New singular complex type return parent::addComplexType($type); @@ -75,30 +81,16 @@ public function addComplexType($type) * @param int $level * @return string */ - protected function _getTypeNameBasedOnNestingLevel($singularType, $level) + protected function _getTypeBasedOnNestingLevel($singularType, $level) { if($level == 0) { // This is not an Array anymore, return the xsd simple type - return $singularType; + return $this->getContext()->getType($singularType); } else { - $prefix = str_repeat('ArrayOf', $level); - $xsdType = $this->_getStrippedXsdType($singularType); - $arrayType = $prefix.$xsdType; - return "tns:$arrayType"; + return 'tns:' . str_repeat('ArrayOf', $level) . ucfirst(WSDL::translateType($singularType)); } } - /** - * Strip the xsd: from a singularType and Format it nice for ArrayOf naming - * - * @param string $singularType - * @return string - */ - protected function _getStrippedXsdType($singularType) - { - return ucfirst(substr(strtolower($singularType), 4)); - } - /** * From a nested defintion with type[], get the singular xsd:type * @@ -108,8 +100,7 @@ protected function _getStrippedXsdType($singularType) */ protected function _getSingularType($type) { - $singulartype = $this->getContext()->getType(str_replace('[]', '', $type)); - return $singulartype; + return str_replace('[]', '', $type); } /** @@ -126,23 +117,24 @@ protected function _getNestedCount($type) /** * Append the complex type definition to the WSDL via the context access * - * @param string $arrayType - * @param string $childTypeName + * @param string $arrayTypeName Array type name (e.g. 'ArrayOf...') + * @param string $childType Qualified array items type (e.g. 'xsd:int', 'tns:ArrayOfInt') + * @param string $phpArrayType PHP type (e.g. 'int[][]', '\MyNamespace\MyClassName[][][]') * @return void */ - protected function _addElementFromWSDLAndChildTypes($arrayType, $childTypeName) + protected function _addSequenceType($arrayTypeName, $childType, $phpArrayType) { - if (!in_array($arrayType, $this->getContext()->getTypes())) { + if (!in_array($phpArrayType, $this->getContext()->getTypes())) { $dom = $this->getContext()->toDomDocument(); $complexType = $dom->createElement('xsd:complexType'); - $complexType->setAttribute('name', $arrayType); + $complexType->setAttribute('name', $arrayTypeName); $sequence = $dom->createElement('xsd:sequence'); $element = $dom->createElement('xsd:element'); $element->setAttribute('name', 'item'); - $element->setAttribute('type', $childTypeName); + $element->setAttribute('type', $childType); $element->setAttribute('minOccurs', 0); $element->setAttribute('maxOccurs', 'unbounded'); $sequence->appendChild($element); @@ -150,7 +142,7 @@ protected function _addElementFromWSDLAndChildTypes($arrayType, $childTypeName) $complexType->appendChild($sequence); $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($arrayType); + $this->getContext()->addType($phpArrayType); } } } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 6799ea3d..8c82667f 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -850,6 +850,8 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayS $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyServiceSequence'); $wsdl = $autodiscover->toXml(); +var_dump("\n" . $wsdl) ; exit(); + $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(1, substr_count($wsdl, '')); diff --git a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php index e9400848..ff3265bd 100644 --- a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php +++ b/test/WSDL/ArrayOfTypeSequenceStrategyTest.php @@ -118,12 +118,12 @@ public function testAddComplexTypeObject() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\SequenceTest'); - $this->assertEquals('tns:\ZendTest\Soap\WSDL\SequenceTest', $return); + $this->assertEquals('tns:ZendTest.Soap.WSDL.SequenceTest', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); } @@ -131,20 +131,20 @@ public function testAddComplexTypeObject() public function testAddComplexTypeArrayOfObject() { - $return = $this->wsdl->addComplexType('ZendTest_Soap_TestAsset_ComplexTypeA[]'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTypeA[]'); - $this->assertEquals('tns:ArrayOfZendtest_soap_testasset_complextypea', $return); + $this->assertEquals('tns:ArrayOfZendTest.Soap.TestAsset.ComplexTypeA', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } From 5ba51fdc2d2b614fe7cdd375e4f20a276802e11f Mon Sep 17 00:00:00 2001 From: Alexander Veremyev Date: Wed, 21 Jul 2010 15:35:31 +0400 Subject: [PATCH 053/123] Zend\Soap: improved array types processing. --- src/WSDL.php | 12 ++++---- src/WSDL/Strategy/ArrayOfTypeComplex.php | 6 ++-- src/WSDL/Strategy/ArrayOfTypeSequence.php | 34 ++++++++++------------- src/WSDL/Strategy/DefaultComplexType.php | 2 +- test/AutoDiscoverTest.php | 4 +-- test/WSDL/CompositeStrategyTest.php | 4 +-- test/WSDLTest.php | 15 ++++++---- 7 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/WSDL.php b/src/WSDL.php index a8fa6d32..cb71ec55 100644 --- a/src/WSDL.php +++ b/src/WSDL.php @@ -457,12 +457,13 @@ public function addTypes($types) * Add a complex type name that is part of this WSDL and can be used in signatures. * * @param string $type + * @param string $wsdlType * @return \Zend\Soap\WSDL */ - public function addType($type) + public function addType($type, $wsdlType) { - if(!in_array($type, $this->_includedTypes)) { - $this->_includedTypes[] = $type; + if(!isset($this->_includedTypes[$type])) { + $this->_includedTypes[$type] = $wsdlType; } return $this; } @@ -608,8 +609,9 @@ public static function translateType($type) */ public function addComplexType($type) { - if (in_array($type, $this->getTypes())) { - return 'tns:' . self::translateType($type); + if (array_key_exists($type, $this->getTypes())) { + $definedTypes = $this->getTypes(); + return $definedTypes[$type]; } $this->addSchemaTypeSection(); diff --git a/src/WSDL/Strategy/ArrayOfTypeComplex.php b/src/WSDL/Strategy/ArrayOfTypeComplex.php index e8698464..e697ac47 100644 --- a/src/WSDL/Strategy/ArrayOfTypeComplex.php +++ b/src/WSDL/Strategy/ArrayOfTypeComplex.php @@ -84,7 +84,7 @@ public function addComplexType($type) } // The array for the objects has been created, now build the object definition: - if(!in_array($singularType, $this->getContext()->getTypes())) { + if(!array_key_exists($singularType, $this->getContext()->getTypes())) { parent::addComplexType($singularType); } @@ -98,7 +98,7 @@ protected function _addArrayOfComplexType($singularType, $type) $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType); - if(!in_array($singularType . '[]', $this->getContext()->getTypes())) { + if(!array_key_exists($singularType . '[]', $this->getContext()->getTypes())) { $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $xsdComplexTypeName); @@ -116,7 +116,7 @@ protected function _addArrayOfComplexType($singularType, $type) $xsdRestriction->appendChild($xsdAttribute); $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($singularType . '[]'); + $this->getContext()->addType($singularType . '[]', $xsdComplexTypeName); } return $xsdComplexTypeName; diff --git a/src/WSDL/Strategy/ArrayOfTypeSequence.php b/src/WSDL/Strategy/ArrayOfTypeSequence.php index c6c62b5f..8d9098e3 100644 --- a/src/WSDL/Strategy/ArrayOfTypeSequence.php +++ b/src/WSDL/Strategy/ArrayOfTypeSequence.php @@ -52,25 +52,20 @@ public function addComplexType($type) $singularType = $this->_getSingularType($type); for($i = 1; $i <= $nestedCounter; $i++) { - $complexType = $this->_getTypeBasedOnNestingLevel($singularType, $i); - $complexTypeName = substr($complexType, strpos($complexType, ':') + 1); + $complexType = $this->_getTypeBasedOnNestingLevel($singularType, $i); + $complexTypePhp = $singularType . str_repeat('[]', $i); + $childType = $this->_getTypeBasedOnNestingLevel($singularType, $i-1); - $childType = $this->_getTypeBasedOnNestingLevel($singularType, $i-1); - - $this->_addSequenceType($complexTypeName, - $childType, - $singularType . str_repeat('[]', $i)); + $this->_addSequenceType($complexType, $childType, $complexTypePhp); } - // adding the PHP type which is resolved to a nested XSD type. therefore add only once. - $this->getContext()->addType($type); - return 'tns:' . $complexTypeName; - } else if (!in_array($type, $this->getContext()->getTypes())) { - // New singular complex type - return parent::addComplexType($type); - } else { + return $complexType; + } else if (array_key_exists($type, $this->getContext()->getTypes())) { // Existing complex type return $this->getContext()->getType($type); + } else { + // New singular complex type + return parent::addComplexType($type); } } @@ -117,18 +112,19 @@ protected function _getNestedCount($type) /** * Append the complex type definition to the WSDL via the context access * - * @param string $arrayTypeName Array type name (e.g. 'ArrayOf...') + * @param string $arrayType Array type name (e.g. 'tns:ArrayOfArrayOfInt') * @param string $childType Qualified array items type (e.g. 'xsd:int', 'tns:ArrayOfInt') * @param string $phpArrayType PHP type (e.g. 'int[][]', '\MyNamespace\MyClassName[][][]') * @return void */ - protected function _addSequenceType($arrayTypeName, $childType, $phpArrayType) + protected function _addSequenceType($arrayType, $childType, $phpArrayType) { - if (!in_array($phpArrayType, $this->getContext()->getTypes())) { + if (!array_key_exists($phpArrayType, $this->getContext()->getTypes())) { $dom = $this->getContext()->toDomDocument(); $complexType = $dom->createElement('xsd:complexType'); - $complexType->setAttribute('name', $arrayTypeName); + // Remove namespace preffix to construct type name + $complexType->setAttribute('name', substr($arrayType, strpos($arrayType, ':') + 1)); $sequence = $dom->createElement('xsd:sequence'); @@ -142,7 +138,7 @@ protected function _addSequenceType($arrayTypeName, $childType, $phpArrayType) $complexType->appendChild($sequence); $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($phpArrayType); + $this->getContext()->addType($phpArrayType, $arrayType); } } } diff --git a/src/WSDL/Strategy/DefaultComplexType.php b/src/WSDL/Strategy/DefaultComplexType.php index 8092f130..465f1973 100644 --- a/src/WSDL/Strategy/DefaultComplexType.php +++ b/src/WSDL/Strategy/DefaultComplexType.php @@ -83,7 +83,7 @@ public function addComplexType($type) $complexType->appendChild($all); $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($type); + $this->getContext()->addType($type, 'tns:' . $translatedType); return 'tns:' . $translatedType; } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 8c82667f..020706fe 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -850,8 +850,6 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayS $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyServiceSequence'); $wsdl = $autodiscover->toXml(); -var_dump("\n" . $wsdl) ; exit(); - $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(1, substr_count($wsdl, '')); @@ -867,7 +865,7 @@ public function testAmpersandInUrlIsCorrectlyEncoded() $autodiscover = new AutoDiscover(); $autodiscover->setUri("http://example.com/?a=b&b=c"); - $autodiscover->setClass("\ZendTest\Soap\TestAsset\Test"); + $autodiscover->setClass('\ZendTest\Soap\TestAsset\Test'); $wsdl = $autodiscover->toXml(); $this->assertContains("http://example.com/?a=b&b=c", $wsdl); diff --git a/test/WSDL/CompositeStrategyTest.php b/test/WSDL/CompositeStrategyTest.php index c00ec04d..49634dcd 100644 --- a/test/WSDL/CompositeStrategyTest.php +++ b/test/WSDL/CompositeStrategyTest.php @@ -112,8 +112,8 @@ public function testCompositeDelegatesAddingComplexTypesToSubStrategies() $wsdl = new WSDL('SomeService', 'http://example.com'); $strategy->setContext($wsdl); - $this->assertEquals('tns:\ZendTest\Soap\WSDL\Book', $strategy->addComplexType('\ZendTest\Soap\WSDL\Book')); - $this->assertEquals('tns:\ZendTest\Soap\WSDL\Cookie', $strategy->addComplexType('\ZendTest\Soap\WSDL\Cookie')); + $this->assertEquals('tns:ZendTest.Soap.WSDL.Book', $strategy->addComplexType('\ZendTest\Soap\WSDL\Book')); + $this->assertEquals('tns:ZendTest.Soap.WSDL.Cookie', $strategy->addComplexType('\ZendTest\Soap\WSDL\Cookie')); $this->assertEquals('xsd:anyType', $strategy->addComplexType('\ZendTest\Soap\WSDL\Anything')); } diff --git a/test/WSDLTest.php b/test/WSDLTest.php index 5ee65a8c..eecf5647 100644 --- a/test/WSDLTest.php +++ b/test/WSDLTest.php @@ -584,11 +584,12 @@ function testAddingSameComplexTypeMoreThanOnceIsIgnored() { try { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass'); - $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass'); + $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass', 'tns:SomeTypeName'); + $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass', 'tns:AnotherTypeName'); $types = $wsdl->getTypes(); $this->assertEquals(1, count($types)); - $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass'), $types); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass' => 'tns:SomeTypeName'), + $types); } catch(WSDLException $e) { $this->fail(); } @@ -598,10 +599,14 @@ function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() { $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); - $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass'), $wsdl->getTypes()); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass' => + 'tns:ZendTest.Soap.TestAsset.WSDLTestClass'), + $wsdl->getTypes()); $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); - $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass'), $wsdl->getTypes()); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass' => + 'tns:ZendTest.Soap.TestAsset.WSDLTestClass'), + $wsdl->getTypes()); } function testAddComplexType() From a74bafef2770b34af71e9658c881a36b89c9aead Mon Sep 17 00:00:00 2001 From: Alexander Veremyev Date: Wed, 21 Jul 2010 17:11:05 +0400 Subject: [PATCH 054/123] Zend\Soap: autodiscovery reqursion processing update. --- src/AutoDiscover.php | 14 +-- src/WSDL.php | 5 +- src/WSDL/Strategy/AbstractStrategy.php | 16 ++++ src/WSDL/Strategy/ArrayOfTypeComplex.php | 95 +++++++++----------- src/WSDL/Strategy/ArrayOfTypeSequence.php | 42 +++++---- src/WSDL/Strategy/DefaultComplexType.php | 17 +++- test/AutoDiscoverTest.php | 4 +- test/WSDL/ArrayOfTypeComplexStrategyTest.php | 3 + 8 files changed, 110 insertions(+), 86 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 380ce851..2e831068 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -300,20 +300,20 @@ public function setClass($class, $namespace = '', $argv = null) { $uri = $this->getUri(); - $translatedClass = WSDL::translateType($class); + $translatedClassName = WSDL::translateType($class); - $wsdl = new $this->_wsdlClass($translatedClass, $uri, $this->_strategy); + $wsdl = new $this->_wsdlClass($translatedClassName, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); - $port = $wsdl->addPortType($translatedClass . 'Port'); - $binding = $wsdl->addBinding($translatedClass . 'Binding', 'tns:' . $translatedClass . 'Port'); + $port = $wsdl->addPortType($translatedClassName . 'Port'); + $binding = $wsdl->addBinding($translatedClassName . 'Binding', 'tns:' . $translatedClassName . 'Port'); $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); - $wsdl->addService($translatedClass . 'Service', - $translatedClass . 'Port', - 'tns:' . $translatedClass . 'Binding', $uri); + $wsdl->addService($translatedClassName . 'Service', + $translatedClassName . 'Port', + 'tns:' . $translatedClassName . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); } diff --git a/src/WSDL.php b/src/WSDL.php index cb71ec55..ea7bcb2f 100644 --- a/src/WSDL.php +++ b/src/WSDL.php @@ -609,9 +609,8 @@ public static function translateType($type) */ public function addComplexType($type) { - if (array_key_exists($type, $this->getTypes())) { - $definedTypes = $this->getTypes(); - return $definedTypes[$type]; + if (isset($this->_includedTypes[$type])) { + return $this->_includedTypes[$type]; } $this->addSchemaTypeSection(); diff --git a/src/WSDL/Strategy/AbstractStrategy.php b/src/WSDL/Strategy/AbstractStrategy.php index 0472c594..ad1c61b3 100644 --- a/src/WSDL/Strategy/AbstractStrategy.php +++ b/src/WSDL/Strategy/AbstractStrategy.php @@ -66,4 +66,20 @@ public function getContext() { return $this->_context; } + + /** + * Look through registered types + * + * @param string $phpType + * @return string + */ + public function scanRegisteredTypes($phpType) + { + if (array_key_exists($phpType, $this->getContext()->getTypes())) { + $soapTypes = $this->getContext()->getTypes(); + return $soapTypes[$phpType]; + } + + return null; + } } diff --git a/src/WSDL/Strategy/ArrayOfTypeComplex.php b/src/WSDL/Strategy/ArrayOfTypeComplex.php index e697ac47..850490ea 100644 --- a/src/WSDL/Strategy/ArrayOfTypeComplex.php +++ b/src/WSDL/Strategy/ArrayOfTypeComplex.php @@ -43,8 +43,6 @@ */ class ArrayOfTypeComplex extends DefaultComplexType { - protected $_inProcess = array(); - /** * Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment. * @@ -53,78 +51,71 @@ class ArrayOfTypeComplex extends DefaultComplexType */ public function addComplexType($type) { - if(isset($this->_inProcess[$type])) { - throw new WSDLException("Infinite recursion, cannot nest '$type' into itself."); + if (($soapType = $this->scanRegisteredTypes($type)) !== null) { + return $soapType; } - $this->_inProcess[$type] = $type; + $singularType = $this->_getSingularPhpType($type); $nestingLevel = $this->_getNestedCount($type); - if($nestingLevel > 1) { + if($nestingLevel == 0) { + return parent::addComplexType($singularType); + } else if($nestingLevel == 1) { + // The following blocks define the Array of Object structure + return $this->_addArrayOfComplexType($singularType, $type); + } else { throw new WSDLException( 'ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ' . 'one level. Use array object properties to return deep nested data.' ); } + } - $singularType = $this->_getSingularPhpType($type); - - if(!class_exists($singularType)) { - throw new WSDLException(sprintf( - 'Cannot add a complex type %s that is not an object or where ' - . 'class could not be found in \'DefaultComplexType\' strategy.', $type - )); - } - - if($nestingLevel == 1) { - // The following blocks define the Array of Object structure - $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type); - } else { - $xsdComplexTypeName = WSDL::translateType($singularType); + /** + * Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment. + * + * @param string $singularType e.g. '\MyNamespace\MyClassname' + * @param string $type e.g. '\MyNamespace\MyClassname[]' + * @return string tns:xsd-type e.g. 'tns:ArrayOfMyNamespace.MyClassname' + */ + protected function _addArrayOfComplexType($singularType, $type) + { + if (($soapType = $this->scanRegisteredTypes($type)) !== null) { + return $soapType; } - // The array for the objects has been created, now build the object definition: - if(!array_key_exists($singularType, $this->getContext()->getTypes())) { - parent::addComplexType($singularType); - } + $xsdComplexTypeName = 'ArrayOf' . WSDL::translateType($singularType); + $xsdComplexType = 'tns:' . $xsdComplexTypeName; - unset($this->_inProcess[$type]); - return 'tns:' . $xsdComplexTypeName; - } + // Register type here to avoid recursion + $this->getContext()->addType($type, $xsdComplexType); - protected function _addArrayOfComplexType($singularType, $type) - { - $dom = $this->getContext()->toDomDocument(); + // Process singular type using DefaultComplexType strategy + parent::addComplexType($singularType); - $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType); - if(!array_key_exists($singularType . '[]', $this->getContext()->getTypes())) { - $complexType = $dom->createElement('xsd:complexType'); - $complexType->setAttribute('name', $xsdComplexTypeName); + // Add array type structure to WSDL document + $dom = $this->getContext()->toDomDocument(); - $complexContent = $dom->createElement('xsd:complexContent'); - $complexType->appendChild($complexContent); + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $xsdComplexTypeName); - $xsdRestriction = $dom->createElement('xsd:restriction'); - $xsdRestriction->setAttribute('base', 'soap-enc:Array'); - $complexContent->appendChild($xsdRestriction); + $complexContent = $dom->createElement('xsd:complexContent'); + $complexType->appendChild($complexContent); - $xsdAttribute = $dom->createElement('xsd:attribute'); - $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType'); - $xsdAttribute->setAttribute('wsdl:arrayType', - 'tns:' . WSDL::translateType($singularType) . '[]'); - $xsdRestriction->appendChild($xsdAttribute); + $xsdRestriction = $dom->createElement('xsd:restriction'); + $xsdRestriction->setAttribute('base', 'soap-enc:Array'); + $complexContent->appendChild($xsdRestriction); - $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($singularType . '[]', $xsdComplexTypeName); - } + $xsdAttribute = $dom->createElement('xsd:attribute'); + $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType'); + $xsdAttribute->setAttribute('wsdl:arrayType', + 'tns:' . WSDL::translateType($singularType) . '[]'); + $xsdRestriction->appendChild($xsdAttribute); - return $xsdComplexTypeName; - } + $this->getContext()->getSchema()->appendChild($complexType); - protected function _getXsdComplexTypeName($type) - { - return 'ArrayOf' . WSDL::translateType($type); + return $xsdComplexType; } /** diff --git a/src/WSDL/Strategy/ArrayOfTypeSequence.php b/src/WSDL/Strategy/ArrayOfTypeSequence.php index 8d9098e3..01e373f4 100644 --- a/src/WSDL/Strategy/ArrayOfTypeSequence.php +++ b/src/WSDL/Strategy/ArrayOfTypeSequence.php @@ -60,9 +60,9 @@ public function addComplexType($type) } return $complexType; - } else if (array_key_exists($type, $this->getContext()->getTypes())) { + } else if (($soapType = $this->scanRegisteredTypes($type)) !== null) { // Existing complex type - return $this->getContext()->getType($type); + return $soapType; } else { // New singular complex type return parent::addComplexType($type); @@ -119,26 +119,32 @@ protected function _getNestedCount($type) */ protected function _addSequenceType($arrayType, $childType, $phpArrayType) { - if (!array_key_exists($phpArrayType, $this->getContext()->getTypes())) { - $dom = $this->getContext()->toDomDocument(); + if (($soapType = $this->scanRegisteredTypes($phpArrayType)) !== null) { + return; + } - $complexType = $dom->createElement('xsd:complexType'); - // Remove namespace preffix to construct type name - $complexType->setAttribute('name', substr($arrayType, strpos($arrayType, ':') + 1)); + // Register type here to avoid recursion + $this->getContext()->addType($phpArrayType, $arrayType); - $sequence = $dom->createElement('xsd:sequence'); - $element = $dom->createElement('xsd:element'); - $element->setAttribute('name', 'item'); - $element->setAttribute('type', $childType); - $element->setAttribute('minOccurs', 0); - $element->setAttribute('maxOccurs', 'unbounded'); - $sequence->appendChild($element); + $dom = $this->getContext()->toDomDocument(); - $complexType->appendChild($sequence); + $arrayTypeName = substr($arrayType, strpos($arrayType, ':') + 1); - $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($phpArrayType, $arrayType); - } + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $arrayTypeName); + + $sequence = $dom->createElement('xsd:sequence'); + + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', 'item'); + $element->setAttribute('type', $childType); + $element->setAttribute('minOccurs', 0); + $element->setAttribute('maxOccurs', 'unbounded'); + $sequence->appendChild($element); + + $complexType->appendChild($sequence); + + $this->getContext()->getSchema()->appendChild($complexType); } } diff --git a/src/WSDL/Strategy/DefaultComplexType.php b/src/WSDL/Strategy/DefaultComplexType.php index 465f1973..319cc1ba 100644 --- a/src/WSDL/Strategy/DefaultComplexType.php +++ b/src/WSDL/Strategy/DefaultComplexType.php @@ -58,12 +58,22 @@ public function addComplexType($type) )); } + if (($soapType = $this->scanRegisteredTypes($type)) !== null) { + return $soapType; + } + $dom = $this->getContext()->toDomDocument(); $class = new \ReflectionClass($type); - $translatedType = Soap\WSDL::translateType($type); + $soapTypeName = Soap\WSDL::translateType($type); + $soapType = 'tns:' . $soapTypeName; + + // Register type here to avoid recursion + $this->getContext()->addType($type, $soapType); + + $complexType = $dom->createElement('xsd:complexType'); - $complexType->setAttribute('name', $translatedType); + $complexType->setAttribute('name', $soapTypeName); $all = $dom->createElement('xsd:all'); @@ -83,8 +93,7 @@ public function addComplexType($type) $complexType->appendChild($all); $this->getContext()->getSchema()->appendChild($complexType); - $this->getContext()->addType($type, 'tns:' . $translatedType); - return 'tns:' . $translatedType; + return $soapType; } } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 020706fe..0f814d54 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -924,10 +924,10 @@ public function testRecursiveWsdlDependencies() public function assertWsdlPathExists($xml, $path) { - $doc = new DOMDocument('UTF-8'); + $doc = new \DOMDocument('UTF-8'); $doc->loadXML($xml); - $xpath = new DOMXPath($doc); + $xpath = new \DOMXPath($doc); $xpath->registerNamespace('wsdl', 'http://schemas.xmlsoap.org/wsdl/'); $nodes = $xpath->query($path); diff --git a/test/WSDL/ArrayOfTypeComplexStrategyTest.php b/test/WSDL/ArrayOfTypeComplexStrategyTest.php index 5167f5d3..2a2c7043 100644 --- a/test/WSDL/ArrayOfTypeComplexStrategyTest.php +++ b/test/WSDL/ArrayOfTypeComplexStrategyTest.php @@ -222,6 +222,9 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllType */ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrowException() { + $this->markTestSkipped('It seems, it\'s obsolete.'); + return; + $this->setExpectedException('Zend\Soap\WSDLException', 'Infinite recursion'); $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\Recursion'); } From 0897c1aa817259493ffc84962d81ea60618d4141 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 21 Jul 2010 13:47:27 -0400 Subject: [PATCH 055/123] WSDL -> Wsdl - Renamed classes/namespaces from WSDL -> Wsdl --- src/AutoDiscover.php | 46 +++--- src/{WSDL.php => Wsdl.php} | 42 ++--- src/{WSDL => Wsdl}/Strategy.php | 6 +- .../Strategy/AbstractStrategy.php | 20 +-- src/{WSDL => Wsdl}/Strategy/AnyType.php | 12 +- .../Strategy/ArrayOfTypeComplex.php | 16 +- .../Strategy/ArrayOfTypeSequence.php | 14 +- src/{WSDL => Wsdl}/Strategy/Composite.php | 54 +++---- .../Strategy/DefaultComplexType.php | 14 +- src/{WSDLException.php => WsdlException.php} | 6 +- test/AutoDiscoverTest.php | 48 +++--- .../{WSDLTestClass.php => WsdlTestClass.php} | 2 +- test/TestAsset/fulltests/server1.php | 2 +- test/TestAsset/fulltests/server2.php | 2 +- .../ArrayOfTypeComplexStrategyTest.php | 18 +-- .../ArrayOfTypeSequenceStrategyTest.php | 18 +-- test/{WSDL => Wsdl}/CompositeStrategyTest.php | 42 ++--- .../{WSDL => Wsdl}/DefaultComplexTypeTest.php | 14 +- test/{WSDLTest.php => WsdlTest.php} | 150 +++++++++--------- 19 files changed, 263 insertions(+), 263 deletions(-) rename src/{WSDL.php => Wsdl.php} (95%) rename src/{WSDL => Wsdl}/Strategy.php (91%) rename src/{WSDL => Wsdl}/Strategy/AbstractStrategy.php (79%) rename src/{WSDL => Wsdl}/Strategy/AnyType.php (83%) rename src/{WSDL => Wsdl}/Strategy/ArrayOfTypeComplex.php (92%) rename src/{WSDL => Wsdl}/Strategy/ArrayOfTypeSequence.php (94%) rename src/{WSDL => Wsdl}/Strategy/Composite.php (77%) rename src/{WSDL => Wsdl}/Strategy/DefaultComplexType.php (90%) rename src/{WSDLException.php => WsdlException.php} (91%) rename test/TestAsset/{WSDLTestClass.php => WsdlTestClass.php} (88%) rename test/{WSDL => Wsdl}/ArrayOfTypeComplexStrategyTest.php (94%) rename test/{WSDL => Wsdl}/ArrayOfTypeSequenceStrategyTest.php (91%) rename test/{WSDL => Wsdl}/CompositeStrategyTest.php (73%) rename test/{WSDL => Wsdl}/DefaultComplexTypeTest.php (85%) rename test/{WSDLTest.php => WsdlTest.php} (87%) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index c88dd15b..b5f9faeb 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -26,7 +26,7 @@ namespace Zend\Soap; use Zend\Uri, - Zend\Soap\WSDL; + Zend\Soap\Wsdl; /** * \Zend\Soap\AutoDiscover @@ -35,7 +35,7 @@ * @uses \Zend\Server\Server * @uses \Zend\Server\Reflection * @uses \Zend\Soap\AutoDiscover\Exception - * @uses \Zend\Soap\WSDL + * @uses \Zend\Soap\Wsdl * @uses \Zend\Uri\Uri * @category Zend * @package Zend_Soap @@ -44,7 +44,7 @@ class AutoDiscover implements \Zend\Server\Server { /** - * @var \Zend\Soap\WSDL + * @var \Zend\Soap\Wsdl */ protected $_wsdl = null; @@ -89,12 +89,12 @@ class AutoDiscover implements \Zend\Server\Server * * @var string */ - protected $_wsdlClass = '\Zend\Soap\WSDL'; + protected $_wsdlClass = '\Zend\Soap\Wsdl'; /** * Constructor * - * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy + * @param boolean|string|\Zend\Soap\Wsdl\Strategy $strategy * @param string|\Zend\Uri\Uri $uri * @param string $wsdlClass */ @@ -108,7 +108,7 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null) } if($wsdlClass !== null) { - $this->setWSDLClass($wsdlClass); + $this->setWsdlClass($wsdlClass); } } @@ -121,7 +121,7 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null) */ public function setUri($uri) { - if(!is_string($uri) && !($uri instanceof URI\Uri)) { + if(!is_string($uri) && !($uri instanceof Uri\Uri)) { throw new AutoDiscoverException( 'No uri given to \Zend\Soap\AutoDiscover::setUri as string or \Zend\Uri\Uri instance.' ); @@ -129,7 +129,7 @@ public function setUri($uri) $this->_uri = $uri; // change uri in WSDL file also if existant - if($this->_wsdl instanceof WSDL) { + if($this->_wsdl instanceof Wsdl) { $this->_wsdl->setUri($uri); } @@ -162,11 +162,11 @@ public function getUri() * @param string $wsdlClass * @return \Zend\Soap\AutoDiscover */ - public function setWSDLClass($wsdlClass) + public function setWsdlClass($wsdlClass) { - if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\WSDL')) { + if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\Wsdl')) { throw new AutoDiscoverException( - 'No \Zend\Soap\WSDL subclass given to Zend\Soap\AutoDiscover::setWSDLClass as string.' + 'No \Zend\Soap\Wsdl subclass given to Zend\Soap\AutoDiscover::setWsdlClass as string.' ); } $this->_wsdlClass = $wsdlClass; @@ -179,7 +179,7 @@ public function setWSDLClass($wsdlClass) * * @return string */ - public function getWSDLClass() + public function getWsdlClass() { return $this->_wsdlClass; } @@ -276,13 +276,13 @@ protected function getRequestUriWithoutParameters() /** * Set the strategy that handles functions and classes that are added AFTER this call. * - * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy + * @param boolean|string|\Zend\Soap\Wsdl\Strategy $strategy * @return \Zend\Soap\AutoDiscover */ public function setComplexTypeStrategy($strategy) { $this->_strategy = $strategy; - if($this->_wsdl instanceof WSDL) { + if($this->_wsdl instanceof Wsdl) { $this->_wsdl->setComplexTypeStrategy($strategy); } @@ -300,7 +300,7 @@ public function setClass($class, $namespace = '', $argv = null) { $uri = $this->getUri(); - $translatedClassName = WSDL::translateType($class); + $translatedClassName = Wsdl::translateType($class); $wsdl = new $this->_wsdlClass($translatedClassName, $uri, $this->_strategy); @@ -315,7 +315,7 @@ public function setClass($class, $namespace = '', $argv = null) $translatedClassName . 'Port', 'tns:' . $translatedClassName . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { - $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); + $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; } @@ -338,10 +338,10 @@ public function addFunction($function, $namespace = '') $uri = $this->getUri(); - if (!($this->_wsdl instanceof WSDL)) { + if (!($this->_wsdl instanceof Wsdl)) { $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; - $wsdl = new WSDL($name, $uri, $this->_strategy); + $wsdl = new Wsdl($name, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); @@ -357,7 +357,7 @@ public function addFunction($function, $namespace = '') foreach ($function as $func) { $method = $this->_reflection->reflectFunction($func); - $this->_addFunctionToWSDL($method, $wsdl, $port, $binding); + $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; } @@ -366,12 +366,12 @@ public function addFunction($function, $namespace = '') * Add a function to the WSDL document. * * @param $function \Zend\Server\Reflection\AbstractFunction function to add - * @param $wsdl \Zend\Soap\WSDL WSDL document + * @param $wsdl \Zend\Soap\Wsdl WSDL document * @param $port object wsdl:portType * @param $binding object wsdl:binding * @return void */ - protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) + protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) { $uri = $this->getUri(); @@ -389,7 +389,7 @@ protected function _addFunctionToWSDL($function, $wsdl, $port, $binding) throw new AutoDiscoverException("No prototypes could be found for the '" . $function->getName() . "' function"); } - $functionName = WSDL::translateType($function->getName()); + $functionName = Wsdl::translateType($function->getName()); // Add the input message (parameters) $args = array(); @@ -562,7 +562,7 @@ public function setPersistence($mode) */ public function getType($type) { - if (!($this->_wsdl instanceof WSDL)) { + if (!($this->_wsdl instanceof Wsdl)) { /** @todo Exception throwing may be more correct */ // WSDL is not defined yet, so we can't recognize type in context of current service diff --git a/src/WSDL.php b/src/Wsdl.php similarity index 95% rename from src/WSDL.php rename to src/Wsdl.php index 4cafeacd..b9bfc813 100644 --- a/src/WSDL.php +++ b/src/Wsdl.php @@ -27,21 +27,21 @@ use Zend\Uri\Url; /** - * \Zend\Soap\WSDL + * \Zend\Soap\Wsdl * * @uses DOMDocument * @uses \Zend\Server\Exception - * @uses \Zend\Soap\WSDLException - * @uses \Zend\Soap\WSDL\Strategy\AbstractStrategy - * @uses \Zend\Soap\WSDL\Strategy\AnyType - * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType - * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface + * @uses \Zend\Soap\WsdlException + * @uses \Zend\Soap\Wsdl\Strategy\AbstractStrategy + * @uses \Zend\Soap\Wsdl\Strategy\AnyType + * @uses \Zend\Soap\Wsdl\Strategy\DefaultComplexType + * @uses \Zend\Soap\Wsdl\Strategy\StrategyInterface * @category Zend * @package Zend_Soap * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class WSDL +class Wsdl { /** * @var object DomDocument Instance @@ -81,7 +81,7 @@ class WSDL * * @param string $name Name of the Web Service being Described * @param string|\Zend\URL $uri URI where the WSDL will be available - * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy + * @param boolean|string|\Zend\Soap\Wsdl\Strategy $strategy */ public function __construct($name, $uri, $strategy = true) { @@ -104,7 +104,7 @@ public function __construct($name, $uri, $strategy = true) xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>"; $this->_dom = new \DOMDocument(); if (!$this->_dom->loadXML($wsdl)) { - throw new WSDLException('Unable to create DomDocument'); + throw new WsdlException('Unable to create DomDocument'); } else { $this->_wsdl = $this->_dom->documentElement; } @@ -116,7 +116,7 @@ public function __construct($name, $uri, $strategy = true) * Set a new uri for this WSDL * * @param string|\Zend\URL $uri - * @return \Zend\Server\WSDL + * @return \Zend\Server\Wsdl */ public function setUri($uri) { @@ -141,27 +141,27 @@ public function setUri($uri) * Set a strategy for complex type detection and handling * * @todo Boolean is for backwards compability with extractComplexType object var. Remove it in later versions. - * @param boolean|string|\Zend\Soap\WSDL\Strategy $strategy - * @return \Zend\Soap\WSDL + * @param boolean|string|\Zend\Soap\Wsdl\Strategy $strategy + * @return \Zend\Soap\Wsdl */ public function setComplexTypeStrategy($strategy) { if($strategy === true) { - $strategy = new WSDL\Strategy\DefaultComplexType(); + $strategy = new Wsdl\Strategy\DefaultComplexType(); } else if($strategy === false) { - $strategy = new WSDL\Strategy\AnyType(); + $strategy = new Wsdl\Strategy\AnyType(); } else if(is_string($strategy)) { if(class_exists($strategy)) { $strategy = new $strategy(); } else { - throw new WSDLException( + throw new WsdlException( sprintf("Strategy with name '%s does not exist.", $strategy )); } } - if(!($strategy instanceof WSDL\Strategy)) { - throw new WSDLException('Set a strategy that is not of type \'Zend\Soap\WSDL\Strategy\''); + if(!($strategy instanceof Wsdl\Strategy)) { + throw new WsdlException('Set a strategy that is not of type \'Zend\Soap\Wsdl\Strategy\''); } $this->_strategy = $strategy; return $this; @@ -170,7 +170,7 @@ public function setComplexTypeStrategy($strategy) /** * Get the current complex type strategy * - * @return \Zend\Soap\WSDL\Strategy + * @return \Zend\Soap\Wsdl\Strategy */ public function getComplexTypeStrategy() { @@ -458,7 +458,7 @@ public function addTypes($types) * * @param string $type * @param string $wsdlType - * @return \Zend\Soap\WSDL + * @return \Zend\Soap\Wsdl */ public function addType($type, $wsdlType) { @@ -572,7 +572,7 @@ public function getType($type) /** * This function makes sure a complex types section and schema additions are set. * - * @return \Zend\Soap\WSDL + * @return \Zend\Soap\Wsdl */ public function addSchemaTypeSection() { @@ -629,7 +629,7 @@ public function addComplexType($type) private function _parseElement($element) { if (!is_array($element)) { - throw new WSDLException("The 'element' parameter needs to be an associative array."); + throw new WsdlException("The 'element' parameter needs to be an associative array."); } $elementXml = $this->_dom->createElement('xsd:element'); diff --git a/src/WSDL/Strategy.php b/src/Wsdl/Strategy.php similarity index 91% rename from src/WSDL/Strategy.php rename to src/Wsdl/Strategy.php index d0f2e683..abb3d696 100644 --- a/src/WSDL/Strategy.php +++ b/src/Wsdl/Strategy.php @@ -23,10 +23,10 @@ /** * @namespace */ -namespace Zend\Soap\WSDL; +namespace Zend\Soap\Wsdl; /** - * Interface for Zend_Soap_WSDL_Strategy. + * Interface for Zend_Soap_Wsdl_Strategy. * * @category Zend * @package Zend_Soap @@ -41,7 +41,7 @@ interface Strategy * * @param $context */ - public function setContext(\Zend\Soap\WSDL $context); + public function setContext(\Zend\Soap\Wsdl $context); /** * Create a complex type based on a strategy diff --git a/src/WSDL/Strategy/AbstractStrategy.php b/src/Wsdl/Strategy/AbstractStrategy.php similarity index 79% rename from src/WSDL/Strategy/AbstractStrategy.php rename to src/Wsdl/Strategy/AbstractStrategy.php index ad1c61b3..45dc32f3 100644 --- a/src/WSDL/Strategy/AbstractStrategy.php +++ b/src/Wsdl/Strategy/AbstractStrategy.php @@ -23,14 +23,14 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\Wsdl\Strategy; -use Zend\Soap\WSDL\Strategy; +use Zend\Soap\Wsdl\Strategy; /** - * Abstract class for Zend_Soap_WSDL_Strategy. + * Abstract class for Zend_Soap_Wsdl_Strategy. * - * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface + * @uses \Zend\Soap\Wsdl\Strategy * @category Zend * @package Zend_Soap * @subpackage WSDL @@ -42,25 +42,25 @@ abstract class AbstractStrategy implements Strategy /** * Context object * - * @var \Zend\Soap\WSDL + * @var \Zend\Soap\Wsdl */ protected $_context; /** - * Set the Zend_Soap_WSDL Context object this strategy resides in. + * Set the Zend_Soap_Wsdl Context object this strategy resides in. * - * @param \Zend\Soap\WSDL $context + * @param \Zend\Soap\Wsdl $context * @return void */ - public function setContext(\Zend\Soap\WSDL $context) + public function setContext(\Zend\Soap\Wsdl $context) { $this->_context = $context; } /** - * Return the current Zend_Soap_WSDL context object + * Return the current Zend_Soap_Wsdl context object * - * @return \Zend\Soap\WSDL + * @return \Zend\Soap\Wsdl */ public function getContext() { diff --git a/src/WSDL/Strategy/AnyType.php b/src/Wsdl/Strategy/AnyType.php similarity index 83% rename from src/WSDL/Strategy/AnyType.php rename to src/Wsdl/Strategy/AnyType.php index c435e0e7..e0dec499 100644 --- a/src/WSDL/Strategy/AnyType.php +++ b/src/Wsdl/Strategy/AnyType.php @@ -23,14 +23,14 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\Wsdl\Strategy; -use Zend\Soap\WSDL\Strategy; +use Zend\Soap\Wsdl\Strategy; /** - * Zend_Soap_WSDL_Strategy_AnyType + * Zend_Soap_Wsdl_Strategy_AnyType * - * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface + * @uses \Zend\Soap\Wsdl\Strategy\StrategyInterface * @category Zend * @package Zend_Soap * @subpackage WSDL @@ -42,9 +42,9 @@ class AnyType implements Strategy /** * Not needed in this strategy. * - * @param \Zend\Soap\WSDL $context + * @param \Zend\Soap\Wsdl $context */ - public function setContext(\Zend\Soap\WSDL $context) + public function setContext(\Zend\Soap\Wsdl $context) { } diff --git a/src/WSDL/Strategy/ArrayOfTypeComplex.php b/src/Wsdl/Strategy/ArrayOfTypeComplex.php similarity index 92% rename from src/WSDL/Strategy/ArrayOfTypeComplex.php rename to src/Wsdl/Strategy/ArrayOfTypeComplex.php index 850490ea..7e8b5fc6 100644 --- a/src/WSDL/Strategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/Strategy/ArrayOfTypeComplex.php @@ -23,18 +23,18 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\Wsdl\Strategy; use Zend\Soap; -use Zend\Soap\WSDL; -use Zend\Soap\WSDLException; +use Zend\Soap\Wsdl; +use Zend\Soap\WsdlException; /** * ArrayOfTypeComplex strategy * - * @uses \Zend\Soap\WSDL\Exception - * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType + * @uses \Zend\Soap\Wsdl\Exception + * @uses \Zend\Soap\Wsdl\Strategy\DefaultComplexType * @category Zend * @package Zend_Soap * @subpackage WSDL @@ -64,7 +64,7 @@ public function addComplexType($type) // The following blocks define the Array of Object structure return $this->_addArrayOfComplexType($singularType, $type); } else { - throw new WSDLException( + throw new WsdlException( 'ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ' . 'one level. Use array object properties to return deep nested data.' ); @@ -84,7 +84,7 @@ protected function _addArrayOfComplexType($singularType, $type) return $soapType; } - $xsdComplexTypeName = 'ArrayOf' . WSDL::translateType($singularType); + $xsdComplexTypeName = 'ArrayOf' . Wsdl::translateType($singularType); $xsdComplexType = 'tns:' . $xsdComplexTypeName; // Register type here to avoid recursion @@ -110,7 +110,7 @@ protected function _addArrayOfComplexType($singularType, $type) $xsdAttribute = $dom->createElement('xsd:attribute'); $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType'); $xsdAttribute->setAttribute('wsdl:arrayType', - 'tns:' . WSDL::translateType($singularType) . '[]'); + 'tns:' . Wsdl::translateType($singularType) . '[]'); $xsdRestriction->appendChild($xsdAttribute); $this->getContext()->getSchema()->appendChild($complexType); diff --git a/src/WSDL/Strategy/ArrayOfTypeSequence.php b/src/Wsdl/Strategy/ArrayOfTypeSequence.php similarity index 94% rename from src/WSDL/Strategy/ArrayOfTypeSequence.php rename to src/Wsdl/Strategy/ArrayOfTypeSequence.php index 01e373f4..37f41faf 100644 --- a/src/WSDL/Strategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -22,20 +22,20 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\Wsdl\Strategy; + +use Zend\Soap\Wsdl; /** - * Zend_Soap_WSDL_Strategy_ArrayOfTypeSequence + * Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence * - * @uses \Zend\Soap\WSDL\Strategy\DefaultComplexType + * @uses \Zend\Soap\Wsdl\Strategy\DefaultComplexType * @category Zend * @package Zend_Soap * @subpackage WSDL * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -use Zend\Soap\WSDL; - class ArrayOfTypeSequence extends DefaultComplexType { /** @@ -82,14 +82,14 @@ protected function _getTypeBasedOnNestingLevel($singularType, $level) // This is not an Array anymore, return the xsd simple type return $this->getContext()->getType($singularType); } else { - return 'tns:' . str_repeat('ArrayOf', $level) . ucfirst(WSDL::translateType($singularType)); + return 'tns:' . str_repeat('ArrayOf', $level) . ucfirst(Wsdl::translateType($singularType)); } } /** * From a nested defintion with type[], get the singular xsd:type * - * @throws \Zend\Soap\WSDLException When no xsd:simpletype can be detected. + * @throws \Zend\Soap\WsdlException When no xsd:simpletype can be detected. * @param string $type * @return string */ diff --git a/src/WSDL/Strategy/Composite.php b/src/Wsdl/Strategy/Composite.php similarity index 77% rename from src/WSDL/Strategy/Composite.php rename to src/Wsdl/Strategy/Composite.php index 53008cdc..349eb95c 100644 --- a/src/WSDL/Strategy/Composite.php +++ b/src/Wsdl/Strategy/Composite.php @@ -23,17 +23,17 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\Wsdl\Strategy; -use Zend\Soap\WSDL\Strategy, - Zend\Soap\WSDLException, - Zend\Soap\WSDL; +use Zend\Soap\Wsdl\Strategy, + Zend\Soap\WsdlException, + Zend\Soap\Wsdl; /** - * Zend_Soap_WSDL_Strategy_Composite + * Zend_Soap_Wsdl_Strategy_Composite * - * @uses \Zend\Soap\WSDL\Exception - * @uses \Zend\Soap\WSDL\Strategy\StrategyInterface + * @uses \Zend\Soap\Wsdl\Exception + * @uses \Zend\Soap\Wsdl\Strategy\StrategyInterface * @category Zend * @package Zend_Soap * @subpackage WSDL @@ -52,25 +52,25 @@ class Composite implements Strategy /** * Default Strategy of this composite * - * @var string|\Zend\Soap\WSDL\Strategy + * @var string|\Zend\Soap\Wsdl\Strategy */ protected $_defaultStrategy; /** * Context WSDL file that this composite serves * - * @var \Zend\Soap\WSDL|null + * @var \Zend\Soap\Wsdl|null */ protected $_context; /** * Construct Composite WSDL Strategy. * - * @throws \Zend\Soap\WSDLException + * @throws \Zend\Soap\WsdlException * @param array $typeMap - * @param string|\Zend\Soap\WSDL\Strategy $defaultStrategy + * @param string|\Zend\Soap\Wsdl\Strategy $defaultStrategy */ - public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap\WSDL\Strategy\DefaultComplexType') + public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap\Wsdl\Strategy\DefaultComplexType') { foreach($typeMap AS $type => $strategy) { $this->connectTypeToStrategy($type, $strategy); @@ -81,15 +81,15 @@ public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap /** * Connect a complex type to a given strategy. * - * @throws \Zend\Soap\WSDL\Exception + * @throws \Zend\Soap\WsdlException * @param string $type - * @param string|\Zend\Soap\WSDL\Strategy $strategy - * @return \Zend\Soap\WSDL\Strategy\Composite + * @param string|\Zend\Soap\Wsdl\Strategy $strategy + * @return \Zend\Soap\Wsdl\Strategy\Composite */ public function connectTypeToStrategy($type, $strategy) { if(!is_string($type)) { - throw new WSDLException('Invalid type given to Composite Type Map.'); + throw new WsdlException('Invalid type given to Composite Type Map.'); } $this->_typeMap[$type] = $strategy; return $this; @@ -98,9 +98,9 @@ public function connectTypeToStrategy($type, $strategy) /** * Return default strategy of this composite * - * @throws \Zend\Soap\WSDLException + * @throws \Zend\Soap\WsdlException * @param string $type - * @return \Zend\Soap\WSDL\Strategy + * @return \Zend\Soap\Wsdl\Strategy */ public function getDefaultStrategy() { @@ -109,7 +109,7 @@ public function getDefaultStrategy() $strategy = new $strategy; } if( !($strategy instanceof Strategy) ) { - throw new WSDLException( + throw new WsdlException( 'Default Strategy for Complex Types is not a valid strategy object.' ); } @@ -120,9 +120,9 @@ public function getDefaultStrategy() /** * Return specific strategy or the default strategy of this type. * - * @throws \Zend\Soap\WSDLException + * @throws \Zend\Soap\WsdlException * @param string $type - * @return \Zend\Soap\WSDL\Strategy + * @return \Zend\Soap\Wsdl\Strategy */ public function getStrategyOfType($type) { @@ -134,7 +134,7 @@ public function getStrategyOfType($type) } if( !($strategy instanceof Strategy) ) { - throw new WSDLException( + throw new WsdlException( "Strategy for Complex Type '$type' is not a valid strategy object." ); } @@ -148,9 +148,9 @@ public function getStrategyOfType($type) /** * Method accepts the current WSDL context file. * - * @param \Zend\Soap\WSDL $context + * @param \Zend\Soap\Wsdl $context */ - public function setContext(WSDL $context) + public function setContext(Wsdl $context) { $this->_context = $context; return $this; @@ -159,14 +159,14 @@ public function setContext(WSDL $context) /** * Create a complex type based on a strategy * - * @throws \Zend\Soap\WSDLException + * @throws \Zend\Soap\WsdlException * @param string $type * @return string XSD type */ public function addComplexType($type) { - if(!($this->_context instanceof WSDL) ) { - throw new WSDLException( + if(!($this->_context instanceof Wsdl) ) { + throw new WsdlException( "Cannot add complex type '$type', no context is set for this composite strategy." ); } diff --git a/src/WSDL/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php similarity index 90% rename from src/WSDL/Strategy/DefaultComplexType.php rename to src/Wsdl/Strategy/DefaultComplexType.php index 319cc1ba..02173944 100644 --- a/src/WSDL/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -23,18 +23,18 @@ /** * @namespace */ -namespace Zend\Soap\WSDL\Strategy; +namespace Zend\Soap\Wsdl\Strategy; use Zend\Soap; -use Zend\Soap\WSDLException; +use Zend\Soap\WsdlException; /** - * Zend_Soap_WSDL_Strategy_DefaultComplexType + * Zend_Soap_Wsdl_Strategy_DefaultComplexType * * @uses ReflectionClass - * @uses \Zend\Soap\WSDLException - * @uses \Zend\Soap\WSDL\Strategy\AbstractStrategy + * @uses \Zend\Soap\WsdlException + * @uses \Zend\Soap\Wsdl\Strategy\AbstractStrategy * @category Zend * @package Zend_Soap * @subpackage WSDL @@ -52,7 +52,7 @@ class DefaultComplexType extends AbstractStrategy public function addComplexType($type) { if(!class_exists($type)) { - throw new WSDLException(sprintf( + throw new WsdlException(sprintf( 'Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type )); @@ -65,7 +65,7 @@ public function addComplexType($type) $dom = $this->getContext()->toDomDocument(); $class = new \ReflectionClass($type); - $soapTypeName = Soap\WSDL::translateType($type); + $soapTypeName = Soap\Wsdl::translateType($type); $soapType = 'tns:' . $soapTypeName; // Register type here to avoid recursion diff --git a/src/WSDLException.php b/src/WsdlException.php similarity index 91% rename from src/WSDLException.php rename to src/WsdlException.php index 71b8c010..3594eaab 100644 --- a/src/WSDLException.php +++ b/src/WsdlException.php @@ -26,13 +26,13 @@ namespace Zend\Soap; /** - * Zend_Soap_WSDL_Exception + * Zend_Soap_Wsdl_Exception * * @uses \Zend\Soap\Exception * @category Zend * @package Zend_Soap - * @subpackage WSDL + * @subpackage Wsdl * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class WSDLException extends Exception { } +class WsdlException extends Exception { } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 0f814d54..49cced9d 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -58,7 +58,7 @@ public function setUp() $_SERVER['HTTPS'] = "off"; } - protected function sanitizeWSDLXmlOutputForOsCompability($xmlstring) + protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) { $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring); $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); @@ -148,7 +148,7 @@ function testSetClass() . ''; $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); - $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(__DIR__.'/TestAsset/setclass.wsdl'); @@ -305,7 +305,7 @@ function testSetClassWithDifferentStyles() . ''; $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); - $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(__DIR__.'/TestAsset/setclass.wsdl'); @@ -326,10 +326,10 @@ function testSetClassWithResponseReturnPartCompabilityMode() $dom->loadXML(ob_get_clean()); $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); - $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); - $this->assertContains('sanitizeWSDLXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); unlink(__DIR__.'/TestAsset/setclass.wsdl'); } @@ -372,7 +372,7 @@ function testAddFunctionSimple() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(__DIR__.'/TestAsset/addfunction.wsdl'); @@ -422,7 +422,7 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink(__DIR__.'/TestAsset/addfunction.wsdl'); @@ -446,7 +446,7 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); $name = $parts[0]; - $wsdl = $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()); + $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()); $this->assertContains('', $wsdl); $this->assertNotContains('assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -554,7 +554,7 @@ function testAddFunctionMultiple() ''. ''. ''; - $this->assertEquals($wsdl, $this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -583,7 +583,7 @@ public function testUseHttpsSchemaIfAccessedThroughHttps() /** * @group ZF-4117 */ - public function testChangeWSDLUriInConstructor() + public function testChangeWsdlUriInConstructor() { $scriptUri = 'http://localhost/my_script.php'; @@ -601,7 +601,7 @@ public function testChangeWSDLUriInConstructor() /** * @group ZF-4117 */ - public function testChangeWSDLUriViaSetUri() + public function testChangeWsdlUriViaSetUri() { $scriptUri = 'http://localhost/my_script.php'; @@ -631,7 +631,7 @@ public function testSetNonStringNonZendUriUriThrowsException() /** * @group ZF-4117 */ - public function testChangingWSDLUriAfterGenerationIsPossible() + public function testChangingWsdlUriAfterGenerationIsPossible() { $scriptUri = 'http://localhost/my_script.php'; @@ -662,7 +662,7 @@ public function testChangingWSDLUriAfterGenerationIsPossible() * @group ZF-4125 * */ - public function testUsingClassWithMultipleMethodPrototypesProducesValidWSDL() + public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() { $scriptUri = 'http://localhost/my_script.php'; @@ -754,7 +754,7 @@ public function testUsingRequestUriWithoutParametersAsDefault() */ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() { - $server = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $server = new AutoDiscover('Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); $server->setClass('\ZendTest\Soap\TestAsset\AutoDiscoverTestClass2'); ob_start(); @@ -792,8 +792,8 @@ public function testDumpOrXmlOfAutoDiscover() $wsdlOutput = ob_get_clean(); $this->assertEquals( - $this->sanitizeWSDLXmlOutputForOsCompability($wsdlOutput), - $this->sanitizeWSDLXmlOutputForOsCompability($server->toXml()) + $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), + $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) ); ob_start(); @@ -801,15 +801,15 @@ public function testDumpOrXmlOfAutoDiscover() $wsdlOutput = ob_get_clean(); $this->assertEquals( - $this->sanitizeWSDLXmlOutputForOsCompability($wsdlOutput), - $this->sanitizeWSDLXmlOutputForOsCompability($server->toXml()) + $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), + $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) ); } /** * @group ZF-5330 */ - public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWSDL() + public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWsdl() { $server = new AutoDiscover(); try { @@ -832,7 +832,7 @@ public function testDumpOrXmlOnlyAfterGeneratedAutoDiscoverWSDL() */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex() { - $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $autodiscover = new AutoDiscover('Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyService'); $wsdl = $autodiscover->toXml(); @@ -846,7 +846,7 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayC */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence() { - $autodiscover = new AutoDiscover('Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence'); + $autodiscover = new AutoDiscover('Zend\Soap\Wsdl\Strategy\ArrayOfTypeSequence'); $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyServiceSequence'); $wsdl = $autodiscover->toXml(); @@ -907,7 +907,7 @@ public function testNoReturnIsOneWayCallInAddFunction() */ public function testRecursiveWsdlDependencies() { - $autodiscover = new AutoDiscover('\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $autodiscover = new AutoDiscover('\Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); $autodiscover->setClass('\ZendTest\Soap\TestAsset\Recursion'); $wsdl = $autodiscover->toXml(); diff --git a/test/TestAsset/WSDLTestClass.php b/test/TestAsset/WsdlTestClass.php similarity index 88% rename from test/TestAsset/WSDLTestClass.php rename to test/TestAsset/WsdlTestClass.php index ad645b22..73fa75da 100644 --- a/test/TestAsset/WSDLTestClass.php +++ b/test/TestAsset/WsdlTestClass.php @@ -5,7 +5,7 @@ /** * Test Class */ -class WSDLTestClass { +class WsdlTestClass { /** * @var integer */ diff --git a/test/TestAsset/fulltests/server1.php b/test/TestAsset/fulltests/server1.php index e2447fef..83b8459d 100644 --- a/test/TestAsset/fulltests/server1.php +++ b/test/TestAsset/fulltests/server1.php @@ -93,7 +93,7 @@ class ComplexTypeA } if(isset($_GET['wsdl'])) { - $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); + $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; $server = new \Zend\Soap\Server($uri); diff --git a/test/TestAsset/fulltests/server2.php b/test/TestAsset/fulltests/server2.php index 095350ac..09ab9f08 100644 --- a/test/TestAsset/fulltests/server2.php +++ b/test/TestAsset/fulltests/server2.php @@ -68,7 +68,7 @@ public function request($foo, $bar) } if(isset($_GET['wsdl'])) { - $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex()); + $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; $server = new \Zend\Soap\Server($uri); diff --git a/test/WSDL/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php similarity index 94% rename from test/WSDL/ArrayOfTypeComplexStrategyTest.php rename to test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 2a2c7043..4f7bc340 100644 --- a/test/WSDL/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -23,11 +23,11 @@ /** * @namespace */ -namespace ZendTest\Soap\WSDL; +namespace ZendTest\Soap\Wsdl; require_once __DIR__."/../TestAsset/commontypes.php"; -use Zend\Soap\WSDL; +use Zend\Soap\Wsdl; /** @@ -37,7 +37,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_WSDL + * @group Zend_Soap_Wsdl */ class ArrayOfTypeComplexStrategyTest extends \PHPUnit_Framework_TestCase { @@ -46,19 +46,19 @@ class ArrayOfTypeComplexStrategyTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->strategy = new \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex(); - $this->wsdl = new WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); + $this->strategy = new \Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex(); + $this->wsdl = new Wsdl('MyService', 'http://localhost/MyService.php', $this->strategy); } public function testNestingObjectsDeepMakesNoSenseThrowingException() { - $this->setExpectedException('Zend\Soap\WSDLException'); + $this->setExpectedException('Zend\Soap\WsdlException'); $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[][]'); } public function testAddComplexTypeOfNonExistingClassThrowsException() { - $this->setExpectedException('Zend\Soap\WSDLException'); + $this->setExpectedException('Zend\Soap\WsdlException'); $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\UnknownClass[]'); } @@ -88,7 +88,7 @@ public function testThatOverridingStrategyIsReset() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[]'); $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexTest", $return); - // $this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\WSDL\Strategy\ArrayOfTypeComplexStrategy); + // $this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplexStrategy); $wsdl = $this->wsdl->toXML(); } @@ -225,7 +225,7 @@ public function testNestingOfSameTypesDoesNotLeadToInfiniteRecursionButWillThrow $this->markTestSkipped('It seems, it\'s obsolete.'); return; - $this->setExpectedException('Zend\Soap\WSDLException', 'Infinite recursion'); + $this->setExpectedException('Zend\Soap\WsdlException', 'Infinite recursion'); $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\Recursion'); } } diff --git a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php similarity index 91% rename from test/WSDL/ArrayOfTypeSequenceStrategyTest.php rename to test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index ff3265bd..e8796a66 100644 --- a/test/WSDL/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -22,7 +22,7 @@ /** * @namespace */ -namespace ZendTest\Soap\WSDL; +namespace ZendTest\Soap\Wsdl; require_once __DIR__ . '/../TestAsset/commontypes.php'; @@ -33,7 +33,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_WSDL + * @group Zend_Soap_Wsdl */ class ArrayOfTypeSequenceStrategyTest extends \PHPUnit_Framework_TestCase { @@ -42,8 +42,8 @@ class ArrayOfTypeSequenceStrategyTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->strategy = new \Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence(); - $this->wsdl = new \Zend\Soap\WSDL('MyService', 'http://localhost/MyService.php', $this->strategy); + $this->strategy = new \Zend\Soap\Wsdl\Strategy\ArrayOfTypeSequence(); + $this->wsdl = new \Zend\Soap\Wsdl('MyService', 'http://localhost/MyService.php', $this->strategy); } public function testFunctionReturningSimpleArrayOfInts() @@ -116,14 +116,14 @@ public function testFunctionReturningMultipleNestedArrayOfType() public function testAddComplexTypeObject() { - $return = $this->wsdl->addComplexType('\ZendTest\Soap\WSDL\SequenceTest'); + $return = $this->wsdl->addComplexType('\ZendTest\Soap\Wsdl\SequenceTest'); - $this->assertEquals('tns:ZendTest.Soap.WSDL.SequenceTest', $return); + $this->assertEquals('tns:ZendTest.Soap.Wsdl.SequenceTest', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); } @@ -151,8 +151,8 @@ public function testAddComplexTypeArrayOfObject() public function testAddComplexTypeOfNonExistingClassThrowsException() { - $this->setExpectedException('\Zend\Soap\WSDLException'); - $this->wsdl->addComplexType('ZendTest\Soap\WSDL\UnknownClass[]'); + $this->setExpectedException('\Zend\Soap\WsdlException'); + $this->wsdl->addComplexType('ZendTest\Soap\Wsdl\UnknownClass[]'); } } diff --git a/test/WSDL/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php similarity index 73% rename from test/WSDL/CompositeStrategyTest.php rename to test/Wsdl/CompositeStrategyTest.php index 49634dcd..93784cf1 100644 --- a/test/WSDL/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -22,10 +22,10 @@ /** * @namespace */ -namespace ZendTest\Soap\WSDL; -use Zend\Soap\WSDL\Strategy, - Zend\Soap\WSDL, - Zend\Soap\WSDLException; +namespace ZendTest\Soap\Wsdl; +use Zend\Soap\Wsdl\Strategy, + Zend\Soap\Wsdl, + Zend\Soap\WsdlException; /** * @package Zend_Soap @@ -33,7 +33,7 @@ */ -/** Zend_Soap_WSDL */ +/** Zend_Soap_Wsdl */ /** @@ -43,14 +43,14 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_WSDL + * @group Zend_Soap_Wsdl */ class CompositeStrategyTest extends \PHPUnit_Framework_TestCase { public function testCompositeApiAddingStragiesToTypes() { - $strategy = new Strategy\Composite(array(), '\Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence'); - $strategy->connectTypeToStrategy('Book', '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $strategy = new Strategy\Composite(array(), '\Zend\Soap\Wsdl\Strategy\ArrayOfTypeSequence'); + $strategy->connectTypeToStrategy('Book', '\Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); $bookStrategy = $strategy->getStrategyOfType('Book'); $cookieStrategy = $strategy->getStrategyOfType('Cookie'); @@ -61,9 +61,9 @@ public function testCompositeApiAddingStragiesToTypes() public function testConstructorTypeMapSyntax() { - $typeMap = array('Book' => '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); + $typeMap = array('Book' => '\Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); - $strategy = new Strategy\Composite($typeMap, '\Zend\Soap\WSDL\Strategy\ArrayOfTypeSequence'); + $strategy = new Strategy\Composite($typeMap, '\Zend\Soap\Wsdl\Strategy\ArrayOfTypeSequence'); $bookStrategy = $strategy->getStrategyOfType('Book'); $cookieStrategy = $strategy->getStrategyOfType('Cookie'); @@ -79,7 +79,7 @@ public function testCompositeThrowsExceptionOnInvalidType() $strategy->connectTypeToStrategy(array(), 'strategy'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDLException); + $this->assertTrue($e instanceof WsdlException); } } @@ -92,29 +92,29 @@ public function testCompositeThrowsExceptionOnInvalidStrategy() $book = $strategy->getStrategyOfType('Book'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDLException); + $this->assertTrue($e instanceof WsdlException); } try { $book = $strategy->getStrategyOfType('Anything'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDLException); + $this->assertTrue($e instanceof WsdlException); } } public function testCompositeDelegatesAddingComplexTypesToSubStrategies() { - $strategy = new Strategy\Composite(array(), '\Zend\Soap\WSDL\Strategy\AnyType'); - $strategy->connectTypeToStrategy('\ZendTest\Soap\WSDL\Book', '\Zend\Soap\WSDL\Strategy\ArrayOfTypeComplex'); - $strategy->connectTypeToStrategy('\ZendTest\Soap\WSDL\Cookie', '\Zend\Soap\WSDL\Strategy\DefaultComplexType'); + $strategy = new Strategy\Composite(array(), '\Zend\Soap\Wsdl\Strategy\AnyType'); + $strategy->connectTypeToStrategy('\ZendTest\Soap\Wsdl\Book', '\Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); + $strategy->connectTypeToStrategy('\ZendTest\Soap\Wsdl\Cookie', '\Zend\Soap\Wsdl\Strategy\DefaultComplexType'); - $wsdl = new WSDL('SomeService', 'http://example.com'); + $wsdl = new Wsdl('SomeService', 'http://example.com'); $strategy->setContext($wsdl); - $this->assertEquals('tns:ZendTest.Soap.WSDL.Book', $strategy->addComplexType('\ZendTest\Soap\WSDL\Book')); - $this->assertEquals('tns:ZendTest.Soap.WSDL.Cookie', $strategy->addComplexType('\ZendTest\Soap\WSDL\Cookie')); - $this->assertEquals('xsd:anyType', $strategy->addComplexType('\ZendTest\Soap\WSDL\Anything')); + $this->assertEquals('tns:ZendTest.Soap.Wsdl.Book', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Book')); + $this->assertEquals('tns:ZendTest.Soap.Wsdl.Cookie', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Cookie')); + $this->assertEquals('xsd:anyType', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Anything')); } public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrowsException() @@ -124,7 +124,7 @@ public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrows $strategy->addComplexType('Test'); $this->fail(); } catch(\Exception $e) { - $this->assertTrue($e instanceof WSDLException); + $this->assertTrue($e instanceof WsdlException); } } } diff --git a/test/WSDL/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php similarity index 85% rename from test/WSDL/DefaultComplexTypeTest.php rename to test/Wsdl/DefaultComplexTypeTest.php index 1213c13e..87c73f48 100644 --- a/test/WSDL/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -23,7 +23,7 @@ /** * @namespace */ -namespace ZendTest\Soap\WSDL; +namespace ZendTest\Soap\Wsdl; /** * @category Zend @@ -32,24 +32,24 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_WSDL + * @group Zend_Soap_Wsdl */ class DefaultComplexTypeTest extends \PHPUnit_Framework_TestCase { /** - * @var Zend_Soap_WSDL + * @var Zend_Soap_Wsdl */ private $wsdl; /** - * @var Zend_Soap_WSDL_Strategy_DefaultComplexType + * @var Zend_Soap_Wsdl_Strategy_DefaultComplexType */ private $strategy; public function setUp() { - $this->strategy = new \Zend\Soap\WSDL\Strategy\DefaultComplexType(); - $this->wsdl = new \Zend\Soap\WSDL("TestService", "http://framework.zend.com/soap/unittests"); + $this->strategy = new \Zend\Soap\Wsdl\Strategy\DefaultComplexType(); + $this->wsdl = new \Zend\Soap\Wsdl("TestService", "http://framework.zend.com/soap/unittests"); $this->wsdl->setComplexTypeStrategy($this->strategy); $this->strategy->setContext($this->wsdl); } @@ -59,7 +59,7 @@ public function setUp() */ public function testOnlyPublicPropertiesAreDiscoveredByStrategy() { - $this->strategy->addComplexType('\ZendTest\Soap\WSDL\PublicPrivateProtected'); + $this->strategy->addComplexType('\ZendTest\Soap\Wsdl\PublicPrivateProtected'); $xml = $this->wsdl->toXML(); $this->assertNotContains( PublicPrivateProtected::PROTECTED_VAR_NAME, $xml); diff --git a/test/WSDLTest.php b/test/WsdlTest.php similarity index 87% rename from test/WSDLTest.php rename to test/WsdlTest.php index eecf5647..99fb7c91 100644 --- a/test/WSDLTest.php +++ b/test/WsdlTest.php @@ -24,12 +24,12 @@ * @namespace */ namespace ZendTest\Soap; -use Zend\Soap\WSDL, - Zend\Soap\WSDLException, - Zend\Soap\WSDL\Strategy; +use Zend\Soap\Wsdl, + Zend\Soap\WsdlException, + Zend\Soap\Wsdl\Strategy; /** - * Test cases for Zend_Soap_WSDL + * Test cases for Zend_Soap_Wsdl * * @category Zend * @package Zend_Soap @@ -37,11 +37,11 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap - * @group Zend_Soap_WSDL + * @group Zend_Soap_Wsdl */ -class WSDLTest extends \PHPUnit_Framework_TestCase +class WsdlTest extends \PHPUnit_Framework_TestCase { - protected function sanitizeWSDLXmlOutputForOsCompability($xmlstring) + protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) { $xmlstring = str_replace(array("\r", "\n"), "", $xmlstring); $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); @@ -57,9 +57,9 @@ public function swallowIncludeNotices($errno, $errstr) function testConstructor() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . '' ); } - function testSetUriChangesDomDocumentWSDLStructureTnsAndTargetNamespaceAttributes() + function testSetUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); $wsdl->setUri('http://localhost/MyNewService.php'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'getType('int'); @@ -97,7 +97,7 @@ function testAddMessage() $wsdl->addMessage('myMessage', $messageParts); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); @@ -143,7 +143,7 @@ function testAddPortOperation() $wsdl->addPortOperation($portType, 'operation2', 'tns:operation2Request', 'tns:operation2Response'); $wsdl->addPortOperation($portType, 'operation3', 'tns:operation3Request', 'tns:operation3Response', 'tns:operation3Fault'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -208,7 +208,7 @@ function testAddBindingOperation() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -259,7 +259,7 @@ function testAddSoapBinding() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . '' . '' ); - $wsdl1 = new WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl1 = new Wsdl('MyService', 'http://localhost/MyService.php'); $wsdl1->addPortType('myPortType'); $binding = $wsdl1->addBinding('MyServiceBinding', 'myPortType'); @@ -297,7 +297,7 @@ function testAddSoapBinding() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl1->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl1->toXml()), '' . 'addPortType('myPortType'); $binding = $wsdl->addBinding('MyServiceBinding', 'myPortType'); @@ -339,7 +339,7 @@ function testAddSoapOperation() array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addBinding('MyServiceBinding', 'myPortType'); $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'addPortType('myPortType'); $wsdl->addDocumentation($portType, 'This is a description for Port Type node.'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'getType('int'); @@ -443,15 +443,15 @@ public function testAddDocumentationToSetInsertsBefore() . '' . '' . '', - $this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()) + $this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()) ); } function testToXml() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . 'toDomDocument(); $this->assertTrue($dom instanceOf \DOMDocument); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($dom->saveXML()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), '' . 'dump(); $wsdlDump = ob_get_clean(); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdlDump), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdlDump), '' . 'dump(__DIR__ . '/TestAsset/dumped.wsdl'); $dumpedContent = file_get_contents(__DIR__ . '/TestAsset/dumped.wsdl'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($dumpedContent), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dumpedContent), '' . 'assertEquals('xsd:string', $wsdl->getType('string'), 'xsd:string detection failed.'); $this->assertEquals('xsd:string', $wsdl->getType('str'), 'xsd:string detection failed.'); @@ -534,23 +534,23 @@ function testGetType() function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', true); - $this->assertEquals('tns:ZendTest.Soap.TestAsset.WSDLTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php', true); + $this->assertEquals('tns:ZendTest.Soap.TestAsset.WsdlTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); -// $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', false); -// $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); +// $wsdl2 = new Wsdl('MyService', 'http://localhost/MyService.php', false); +// $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); // $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } function testGetComplexTypeBasedOnStrategiesStringNames() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\DefaultComplexType'); - $this->assertEquals('tns:ZendTest.Soap.TestAsset.WSDLTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php', 'Zend\Soap\Wsdl\Strategy\DefaultComplexType'); + $this->assertEquals('tns:ZendTest.Soap.TestAsset.WsdlTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof Strategy\DefaultComplexType); - $wsdl2 = new WSDL('MyService', 'http://localhost/MyService.php', 'Zend\Soap\WSDL\Strategy\AnyType'); - $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WSDLTestClass')); + $wsdl2 = new Wsdl('MyService', 'http://localhost/MyService.php', 'Zend\Soap\Wsdl\Strategy\AnyType'); + $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Strategy\AnyType); } @@ -561,10 +561,10 @@ function testSettingUnknownStrategyThrowsException() { set_error_handler(array($this, 'swallowIncludeNotices'), E_WARNING); try { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', '\Zend\Soap\WSDL\Strategy\UnknownStrategyType'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php', '\Zend\Soap\Wsdl\Strategy\UnknownStrategyType'); restore_error_handler(); $this->fail(); - } catch(WSDLException $e) { + } catch(WsdlException $e) { } restore_error_handler(); } @@ -572,10 +572,10 @@ function testSettingUnknownStrategyThrowsException() function testSettingInvalidStrategyObjectThrowsException() { try { - $strategy = new TestAsset\WSDLTestClass(); - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php', $strategy); + $strategy = new TestAsset\WsdlTestClass(); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php', $strategy); $this->fail(); - } catch(WSDLException $e) { + } catch(WsdlException $e) { } } @@ -583,39 +583,39 @@ function testSettingInvalidStrategyObjectThrowsException() function testAddingSameComplexTypeMoreThanOnceIsIgnored() { try { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass', 'tns:SomeTypeName'); - $wsdl->addType('\ZendTest\Soap\TestAsset\WSDLTestClass', 'tns:AnotherTypeName'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl->addType('\ZendTest\Soap\TestAsset\WsdlTestClass', 'tns:SomeTypeName'); + $wsdl->addType('\ZendTest\Soap\TestAsset\WsdlTestClass', 'tns:AnotherTypeName'); $types = $wsdl->getTypes(); $this->assertEquals(1, count($types)); - $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass' => 'tns:SomeTypeName'), + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WsdlTestClass' => 'tns:SomeTypeName'), $types); - } catch(WSDLException $e) { + } catch(WsdlException $e) { $this->fail(); } } function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); - $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass' => - 'tns:ZendTest.Soap.TestAsset.WSDLTestClass'), + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); + $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WsdlTestClass' => + 'tns:ZendTest.Soap.TestAsset.WsdlTestClass'), $wsdl->getTypes()); - $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); - $this->assertEquals(array('\ZendTest\Soap\TestAsset\WSDLTestClass' => - 'tns:ZendTest.Soap.TestAsset.WSDLTestClass'), + $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); + $this->assertEquals(array('\ZendTest\Soap\TestAsset\WsdlTestClass' => + 'tns:ZendTest.Soap.TestAsset.WsdlTestClass'), $wsdl->getTypes()); } function testAddComplexType() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); - $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WSDLTestClass'); + $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); - $this->assertEquals($this->sanitizeWSDLXmlOutputForOsCompability($wsdl->toXml()), + $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '' . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -642,7 +642,7 @@ function testAddComplexType() */ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() { - $wsdl = new WSDL('MyService', 'http://localhost/MyService.php'); + $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:string", $wsdl->getType("StrIng")); $this->assertEquals("xsd:string", $wsdl->getType("sTr")); @@ -657,7 +657,7 @@ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() */ public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceBySequenceStrategy() { - $wsdl = new WSDL("MyService", "http://localhost/MyService.php"); + $wsdl = new Wsdl("MyService", "http://localhost/MyService.php"); $wsdl->setComplexTypeStrategy(new Strategy\ArrayOfTypeSequence()); $wsdl->addComplexType("string[]"); @@ -677,7 +677,7 @@ public function testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceByS */ public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() { - $wsdl = new WSDL("MyService", self::URI_WITH_EXPANDED_AMP); + $wsdl = new Wsdl("MyService", self::URI_WITH_EXPANDED_AMP); $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } @@ -686,7 +686,7 @@ public function testHtmlAmpersandInUrlInConstructorIsEncodedCorrectly() */ public function testHtmlAmpersandInUrlInSetUriIsEncodedCorrectly() { - $wsdl = new WSDL("MyService", "http://example.com"); + $wsdl = new Wsdl("MyService", "http://example.com"); $wsdl->setUri(self::URI_WITH_EXPANDED_AMP); $this->assertContains(self::URI_WITH_EXPANDED_AMP, $wsdl->toXML()); } From cf3e018b39fa44658b9e2bce02205128198c6e13 Mon Sep 17 00:00:00 2001 From: rquadling Date: Wed, 14 Jul 2010 15:07:08 +0000 Subject: [PATCH 056/123] Provide support for nillable types in a WSDL file. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22560 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/DefaultComplexType.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index 02173944..3c9cdc6f 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -72,6 +72,8 @@ public function addComplexType($type) $this->getContext()->addType($type, $soapType); + $defaultProperties = $class->getDefaultProperties(); + $complexType = $dom->createElement('xsd:complexType'); $complexType->setAttribute('name', $soapTypeName); @@ -85,8 +87,14 @@ public function addComplexType($type) * node for describing other classes used as attribute types for current class */ $element = $dom->createElement('xsd:element'); - $element->setAttribute('name', $property->getName()); + $element->setAttribute('name', $propertyName = $property->getName()); $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); + + // If the default value is null, then this property is nillable. + if (is_null($defaultProperties[$propertyName])) { + $element->setAttribute('nillable', 'true'); + } + $all->appendChild($element); } } From d48e65325b4d2b886ce8cdf3e2d88bb47b0c197b Mon Sep 17 00:00:00 2001 From: mabe Date: Sat, 24 Jul 2010 16:37:10 +0000 Subject: [PATCH 057/123] ZF-5413: use "$var === null" instaed of "is_null($var)" git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22660 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/DefaultComplexType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index 183943ea..cd205100 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -74,7 +74,7 @@ public function addComplexType($type) $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); // If the default value is null, then this property is nillable. - if (is_null($defaultProperties[$propertyName])) { + if ($defaultProperties[$propertyName] === NULL)) { $element->setAttribute('nillable', 'true'); } From fccbce8c33b999756f74d09c15a15d6f97d7067c Mon Sep 17 00:00:00 2001 From: ramon Date: Sun, 25 Jul 2010 19:35:20 +0000 Subject: [PATCH 058/123] [ZF-5413 & ZF-10224] Zend_Soap_Wsdl: - fixed syntax error. git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22674 44c647ce-9c0f-0410-b52a-842ac1e357ba --- src/Wsdl/Strategy/DefaultComplexType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wsdl/Strategy/DefaultComplexType.php b/src/Wsdl/Strategy/DefaultComplexType.php index cd205100..931caad6 100644 --- a/src/Wsdl/Strategy/DefaultComplexType.php +++ b/src/Wsdl/Strategy/DefaultComplexType.php @@ -74,7 +74,7 @@ public function addComplexType($type) $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); // If the default value is null, then this property is nillable. - if ($defaultProperties[$propertyName] === NULL)) { + if ($defaultProperties[$propertyName] === null) { $element->setAttribute('nillable', 'true'); } From 7db3cfec058f0fc97d7d947ca7ea354a435587ed Mon Sep 17 00:00:00 2001 From: Jonathan Maron Date: Wed, 18 Aug 2010 09:22:26 +0200 Subject: [PATCH 059/123] merging --- src/Client.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index 8c645218..df1659e7 100644 --- a/src/Client.php +++ b/src/Client.php @@ -963,10 +963,11 @@ public function getLastMethod() public function _doRequest(Client\Common $client, $request, $location, $action, $version, $one_way = null) { // Perform request as is - if ($one_way === null) { - return $client->__doRequest($request, $location, $action, $version); + if ($one_way == null) { + return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version); + } else { + return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way); } - return $client->__doRequest($request, $location, $action, $version, $one_way); } /** From 22c643b74ca78d18928a3c70e49e1f796231f87a Mon Sep 17 00:00:00 2001 From: sasezaki Date: Mon, 17 Oct 2011 22:17:47 +0900 Subject: [PATCH 060/123] sync svn r22860 - [ZF-9780] (setters become fluent interfaces) plus some additional dockblocks fixes. --- src/AutoDiscover.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 61fb0af9..fad15dc0 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -108,13 +108,13 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null) /** * Set the location at which the WSDL file will be availabe. * - * @throws \Zend\Soap\AutoDiscover\Exception * @param Uri\Uri|string $uri * @return \Zend\Soap\AutoDiscover + * @throws \Zend\Soap\Exception\InvalidArgumentException */ public function setUri($uri) { - if(!is_string($uri) && !($uri instanceof Uri\Uri)) { + if (!is_string($uri) && !($uri instanceof Uri\Uri)) { throw new Exception\InvalidArgumentException( 'No uri given to \Zend\Soap\AutoDiscover::setUri as string or \Zend\Uri\Uri instance.' ); @@ -122,7 +122,7 @@ public function setUri($uri) $this->_uri = $uri; // change uri in WSDL file also if existant - if($this->_wsdl instanceof Wsdl) { + if ($this->_wsdl instanceof Wsdl) { $this->_wsdl->setUri($uri); } @@ -151,13 +151,13 @@ public function getUri() /** * Set the name of the WSDL handling class. * - * @throws \Zend\Soap\AutoDiscover\Exception * @param string $wsdlClass * @return \Zend\Soap\AutoDiscover + * @throws \Zend\Soap\Exception\InvalidArgumentException */ public function setWsdlClass($wsdlClass) { - if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\Wsdl')) { + if (!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\Wsdl')) { throw new Exception\InvalidArgumentException( 'No \Zend\Soap\Wsdl subclass given to Zend\Soap\AutoDiscover::setWsdlClass as string.' ); @@ -185,6 +185,7 @@ public function getWsdlClass() * * @param array $operationStyle * @return \Zend\Soap\AutoDiscover + * @throws \Zend\Soap\Exception\InvalidArgumentException */ public function setOperationBodyStyle(array $operationStyle=array()) { @@ -288,6 +289,7 @@ public function setComplexTypeStrategy($strategy) * @param string $class Class Name * @param string $namespace Class Namspace - Not Used * @param array $argv Arguments to instantiate the class - Not Used + * @return \Zend\Soap\AutoDiscover */ public function setClass($class, $namespace = '', $argv = null) { @@ -311,6 +313,8 @@ public function setClass($class, $namespace = '', $argv = null) $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; + + return $this; } /** @@ -472,6 +476,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) * * @param string $fault * @param string|int $code + * @throws \Zend\Soap\Exception\UnexpectedValueException */ public function fault($fault = null, $code = null) { @@ -495,6 +500,8 @@ public function handle($request = false) * Proxy to WSDL dump function * * @param string $filename + * @return boolean + * @throws \Zend\Soap\Exception\RuntimeException */ public function dump($filename) { @@ -507,6 +514,9 @@ public function dump($filename) /** * Proxy to WSDL toXml() function + * + * @return string + * @throws \Zend\Soap\Exception\RuntimeException */ public function toXml() { @@ -531,6 +541,7 @@ public function getFunctions() * Load Functions * * @param unknown_type $definition + * @throws \Zend\Soap\Exception\RuntimeException */ public function loadFunctions($definition) { @@ -541,6 +552,7 @@ public function loadFunctions($definition) * Set Persistance * * @param int $mode + * @throws \Zend\Soap\Exception\RuntimeException */ public function setPersistence($mode) { From 1e7d813e9f3a2df0d8dd500eedf2295ae0991426 Mon Sep 17 00:00:00 2001 From: sasezaki Date: Mon, 17 Oct 2011 22:19:24 +0900 Subject: [PATCH 061/123] sync svn r22861 - Zend_Soap: update for [ZF-9780] fix. --- src/AutoDiscover.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index fad15dc0..a88eed3c 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -322,6 +322,7 @@ public function setClass($class, $namespace = '', $argv = null) * * @param string $function Function Name * @param string $namespace Function namespace - Not Used + * @return \Zend\Soap\AutoDiscover */ public function addFunction($function, $namespace = '') { @@ -357,6 +358,8 @@ public function addFunction($function, $namespace = '') $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } $this->_wsdl = $wsdl; + + return $this; } /** From 77767eeb18194bbbd174a7a32265ee3d609047f6 Mon Sep 17 00:00:00 2001 From: sasezaki Date: Mon, 17 Oct 2011 22:43:49 +0900 Subject: [PATCH 062/123] sync svn r23266 - ZF-10542 Zend_Soap_Client unsets options with a value of 0 (svn commit log's issue no ZF-10524 is wrong) --- src/Client.php | 23 ++++++++++++++++------- test/ClientTest.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/Client.php b/src/Client.php index 0a1b021d..fb508bdd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -313,7 +313,7 @@ public function getOptions() * ugly hack as I don't know if checking for '=== null' * breaks some other option */ - if ($key == 'user_agent') { + if (in_array($key, array('user_agent', 'cache_wsdl', 'compression'))) { if ($value === null) { unset($options[$key]); } @@ -752,13 +752,16 @@ public function getHttpsCertPassphrase() /** * Set compression options * - * @param int $compressionOptions + * @param int|null $compressionOptions * @return \Zend\Soap\Client\Client */ public function setCompressionOptions($compressionOptions) { - $this->_compression = $compressionOptions; - + if ($compressionOptions === null) { + $this->_compression = null; + } else { + $this->_compression = (int)$compressionOptions; + } $this->_soapClient = null; return $this; @@ -836,17 +839,23 @@ public function getSoapFeatures() /** * Set the SOAP WSDL Caching Options * - * @param string|int|boolean $caching + * @param string|int|boolean|null $caching * @return \Zend\Soap\Client\Client */ - public function setWSDLCache($options) + public function setWSDLCache($caching) { - $this->_cache_wsdl = $options; + if ($caching === null) { + $this->_cache_wsdl = null; + } else { + $this->_cache_wsdl = (int)$caching; + } return $this; } /** * Get current SOAP WSDL Caching option + * + * @return int */ public function getWSDLCache() { diff --git a/test/ClientTest.php b/test/ClientTest.php index 85b04921..8f43ae47 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -204,6 +204,49 @@ public function testUserAgentAllowsEmptyString() $this->assertArrayNotHasKey('user_agent', $options); } + /** + * @group ZF-10542 + */ + public function testAllowNumericZeroAsValueForCacheWsdlOption() + { + $client = new Client(); + $this->assertNull($client->getWsdlCache()); + $options = $client->getOptions(); + $this->assertArrayNotHasKey('cache_wsdl', $options); + + $client->setWsdlCache(WSDL_CACHE_NONE); + $this->assertSame(WSDL_CACHE_NONE, $client->getWsdlCache()); + $options = $client->getOptions(); + $this->assertSame(WSDL_CACHE_NONE, $options['cache_wsdl']); + + $client->setWsdlCache(null); + $this->assertNull($client->getWsdlCache()); + $options = $client->getOptions(); + $this->assertArrayNotHasKey('cache_wsdl', $options); + } + + /** + * @group ZF-10542 + */ + public function testAllowNumericZeroAsValueForCompressionOptions() + { + $client = new Client(); + $this->assertNull($client->getCompressionOptions()); + $options = $client->getOptions(); + $this->assertArrayNotHasKey('compression', $options); + + $client->setCompressionOptions(SOAP_COMPRESSION_GZIP); + $this->assertSame(SOAP_COMPRESSION_GZIP, $client->getCompressionOptions()); + $options = $client->getOptions(); + $this->assertSame(SOAP_COMPRESSION_GZIP, $options['compression']); + + $client->setCompressionOptions(null); + $this->assertNull($client->getCompressionOptions()); + $options = $client->getOptions(); + $this->assertArrayNotHasKey('compression', $options); + } + + public function testGetFunctions() { $server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl'); From 8a174f00205e1a0eabaf17c28c3688ad2feb4f1f Mon Sep 17 00:00:00 2001 From: sasezaki Date: Mon, 17 Oct 2011 23:38:59 +0900 Subject: [PATCH 063/123] sync svn r23337(ZF-10625), r23341(ZF-10646) - Zend_Soap: fix WSDL generation for one way messages. Fixes [ZF-10646]. Zend_Soap: fix WSDL generation addBindingOperation() fault processing. Fixes [ZF-10625]. --- src/AutoDiscover.php | 6 +++++- src/Wsdl.php | 4 ++-- test/AutoDiscoverTest.php | 1 - test/WsdlTest.php | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index a88eed3c..58994d0f 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -467,7 +467,11 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } // Add the binding operation - $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle, $this->_operationBodyStyle); + if($isOneWayMessage == false) { + $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle, $this->_operationBodyStyle); + } else { + $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle); + } $wsdl->addSoapOperation($operation, $uri . '#' . $functionName); // Add the function name to the list diff --git a/src/Wsdl.php b/src/Wsdl.php index f60529dd..de5214f2 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -314,8 +314,8 @@ public function addBindingOperation($binding, $name, $input = false, $output = f if (isset($fault['name'])) { $node->setAttribute('name', $fault['name']); } - $soap_node = $this->_dom->createElement('soap:body'); - foreach ($output as $name => $value) { + $soap_node = $this->_dom->createElement('soap:fault'); + foreach ($fault as $name => $value) { $soap_node->setAttribute($name, $value); } $node->appendChild($soap_node); diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index a19a43f0..1a460ae7 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -499,7 +499,6 @@ function testAddFunctionMultiple() ''. ''. ''. - ''. ''. ''. ''. diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 19d1837c..1486774c 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -204,7 +204,7 @@ function testAddBindingOperation() 'operation3', array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), - array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") + array('name' => 'MyFault','use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/") ); $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), @@ -234,8 +234,8 @@ function testAddBindingOperation() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' From eae4518f3b5b19f1eb431750a5c3e3de392d64c3 Mon Sep 17 00:00:00 2001 From: sasezaki Date: Mon, 17 Oct 2011 23:56:14 +0900 Subject: [PATCH 064/123] sync svn r24065 ZF-11411 Fixed Zend_Soap_Server to use the xml from DomDocument when passed to handle() --- src/Server.php | 2 +- test/ServerTest.php | 10 ++++++++++ test/TestAsset/commontypes.php | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Server.php b/src/Server.php index be53ff97..22a8a401 100644 --- a/src/Server.php +++ b/src/Server.php @@ -809,7 +809,7 @@ public function handle($request = null) $soap->fault("Sender", $setRequestException->getMessage()); } else { try { - $soap->handle($request); + $soap->handle($this->_request); } catch (\Exception $e) { $fault = $this->fault($e); $soap->fault($fault->faultcode, $fault->faultstring); diff --git a/test/ServerTest.php b/test/ServerTest.php index 2aeb991e..c253b215 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -851,4 +851,14 @@ public function testSetAndGetWSDLCache() $this->assertTrue(isset($options['cache_wsdl'])); $this->assertEquals(100, $options['cache_wsdl']); } + + /** + * @group ZF-11411 + */ + public function testHandleUsesProperRequestParameter() + { + $server = new \ZendTest\Soap\TestAsset\MockServer(); + $r = $server->handle(new \DOMDocument('1.0', 'UTF-8')); + $this->assertTrue(is_string($server->mockSoapServer->handle[0])); + } } diff --git a/test/TestAsset/commontypes.php b/test/TestAsset/commontypes.php index 280c9d1f..56ed9573 100644 --- a/test/TestAsset/commontypes.php +++ b/test/TestAsset/commontypes.php @@ -549,6 +549,24 @@ class TestData2 { public $property2; } +class MockSoapServer { + public $handle = null; + public function handle() + { + $this->handle = func_get_args(); + } + public function __call($name, $args) {} +} + +class MockServer extends \Zend\Soap\Server { + public $mockSoapServer = null; + protected function _getSoap() { + $this->mockSoapServer = new MockSoapServer(); + return $this->mockSoapServer; + } +} + + /** Server test classes */ class ServerTestClass { From 407514de766d77955961f4378d29d83f92f9c3ee Mon Sep 17 00:00:00 2001 From: sasezaki Date: Mon, 17 Oct 2011 23:58:16 +0900 Subject: [PATCH 065/123] sync svn r23590(apply only Soap) - ZF-10881: use ob_get_clean instead of ob_get_contents + ob_end_clean --- src/Client/Local.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Client/Local.php b/src/Client/Local.php index 83b5fc92..ca2e5d06 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -84,8 +84,7 @@ public function _doRequest(Common $client, $request, $location, $action, $versio // Perform request as is ob_start(); $this->_server->handle($request); - $response = ob_get_contents(); - ob_end_clean(); + $response = ob_get_clean(); return $response; } From eeb46c6ab2a2f046fb334842f82ad9ee9ffbfd6e Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 5 Dec 2011 17:16:53 +0100 Subject: [PATCH 066/123] [SOAP] Remove AutoDiscover auto-detection of urls. Autodiscover is not responsible for this kind of code. --- src/AutoDiscover.php | 68 +++-------------------- test/AutoDiscoverTest.php | 113 ++++++++++++-------------------------- 2 files changed, 43 insertions(+), 138 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 0a1a23e8..49a4120d 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -139,16 +139,14 @@ public function setUri($uri) */ public function getUri() { - if($this->_uri !== null) { - $uri = $this->_uri; - } else { - $schema = $this->getSchema(); - $host = $this->getHostName(); - $scriptName = $this->getRequestUriWithoutParameters(); - $uri = Uri\UriFactory::factory($schema . '://' . $host . $scriptName); - $this->setUri($uri); + if($this->_uri === null) { + throw new Exception\RuntimeException("Missing uri. You have to explicitly configure the Endpoint Uri by calling AutoDiscover#setUri()."); + } + if (is_string($this->_uri)) { + $this->_uri = Uri\UriFactory::factory($this->_uri); } - return $uri; + + return $this->_uri; } /** @@ -218,58 +216,6 @@ public function setBindingStyle(array $bindingStyle=array()) return $this; } - /** - * Detect and returns the current HTTP/HTTPS Schema - * - * @return string - */ - protected function getSchema() - { - $schema = "http"; - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { - $schema = 'https'; - } - return $schema; - } - - /** - * Detect and return the current hostname - * - * @return string - */ - protected function getHostName() - { - if(isset($_SERVER['HTTP_HOST'])) { - $host = $_SERVER['HTTP_HOST']; - } else { - $host = $_SERVER['SERVER_NAME']; - } - return $host; - } - - /** - * Detect and return the current script name without parameters - * - * @return string - */ - protected function getRequestUriWithoutParameters() - { - if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch - $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; - } elseif (isset($_SERVER['REQUEST_URI'])) { - $requestUri = $_SERVER['REQUEST_URI']; - } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI - $requestUri = $_SERVER['ORIG_PATH_INFO']; - } else { - $requestUri = $_SERVER['SCRIPT_NAME']; - } - if( ($pos = strpos($requestUri, "?")) !== false) { - $requestUri = substr($requestUri, 0, $pos); - } - - return $requestUri; - } - /** * Set the strategy that handles functions and classes that are added AFTER this call. * diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index d9b26f48..1357a2be 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -56,6 +56,13 @@ public function setUp() $_SERVER['SCRIPT_NAME'] = '/my_script.php'; $_SERVER['HTTPS'] = "off"; } + + protected function createAutodiscoverService() + { + $server = new AutoDiscover(); + $server->setUri('http://localhost/my_script.php'); + return $server; + } protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) { @@ -68,7 +75,7 @@ function testSetClass() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); @@ -157,7 +164,7 @@ function testSetClassWithDifferentStyles() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->setClass('\ZendTest\Soap\TestAsset\Test'); @@ -317,7 +324,7 @@ function testSetClassWithResponseReturnPartCompabilityMode() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); @@ -338,7 +345,7 @@ function testAddFunctionSimple() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); @@ -381,7 +388,7 @@ function testAddFunctionSimpleWithDifferentStyle() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); @@ -434,7 +441,7 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); @@ -457,7 +464,7 @@ function testAddFunctionMultiple() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc2'); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc3'); @@ -560,24 +567,6 @@ function testAddFunctionMultiple() unlink(__DIR__.'/TestAsset/addfunction2.wsdl'); } - /** - * @group ZF-4117 - */ - public function testUseHttpsSchemaIfAccessedThroughHttps() - { - $_SERVER['HTTPS'] = "on"; - $httpsScriptUri = 'https://localhost/my_script.php'; - - $server = new AutoDiscover(); - $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - - ob_start(); - $server->handle(); - $wsdlOutput = ob_get_clean(); - - $this->assertContains($httpsScriptUri, $wsdlOutput); - } - /** * @group ZF-4117 */ @@ -603,7 +592,7 @@ public function testChangeWsdlUriViaSetUri() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setUri("http://example.com/service.php"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); @@ -617,7 +606,7 @@ public function testChangeWsdlUriViaSetUri() public function testSetNonStringNonZendUriUriThrowsException() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'No uri given to'); $server->setUri(array("bogus")); @@ -630,7 +619,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setUri("http://example.com/service.php"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); @@ -661,7 +650,7 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() { $scriptUri = 'http://localhost/my_script.php'; - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->setClass('\ZendTest\Soap\TestAsset\TestFixingMultiplePrototypes'); ob_start(); @@ -674,7 +663,7 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnBadPersistence() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Function has no use in AutoDiscover'); $server->setPersistence("bogus"); @@ -683,7 +672,7 @@ public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnBadPersistence( public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnFault() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $this->setExpectedException('Zend\Soap\Exception\UnexpectedValueException', 'Function has no use in AutoDiscover'); $server->fault(); @@ -691,7 +680,7 @@ public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnFault() public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnLoadFunctionsCall() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Function has no use in AutoDiscover'); $server->loadFunctions("bogus"); @@ -699,7 +688,7 @@ public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnLoadFunctionsCa public function testGetFunctions() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $server->setClass('\ZendTest\Soap\TestAsset\Test'); @@ -709,47 +698,14 @@ public function testGetFunctions() $functions ); } - - /** - * @group ZF-4835 - */ - public function testUsingRequestUriWithoutParametersAsDefault() - { - // Apache - $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost'); - $server = new AutoDiscover(); - $uri = $server->getUri()->toString(); - $this->assertNotContains("?wsdl", $uri); - $this->assertEquals("http://localhost/my_script.php", $uri); - - // Apache plus SSL - $_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on'); - $server = new AutoDiscover(); - $uri = $server->getUri()->toString(); - $this->assertNotContains("?wsdl", $uri); - $this->assertEquals("https://localhost/my_script.php", $uri); - - // IIS 5 + PHP as FastCGI - $_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); - $server = new AutoDiscover(); - $uri = $server->getUri()->toString(); - $this->assertNotContains("?wsdl", $uri); - $this->assertEquals("http://localhost/my_script.php", $uri); - - // IIS - $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost'); - $server = new AutoDiscover(); - $uri = $server->getUri()->toString(); - $this->assertNotContains("?wsdl", $uri); - $this->assertEquals("http://localhost/my_script.php", $uri); - } - + /** * @group ZF-4937 */ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() { - $server = new AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex); + $server = $this->createAutodiscoverService(); + $server->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex); $server->setClass('\ZendTest\Soap\TestAsset\AutoDiscoverTestClass2'); ob_start(); @@ -779,7 +735,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() */ public function testDumpOrXmlOfAutoDiscover() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); @@ -806,7 +762,7 @@ public function testDumpOrXmlOfAutoDiscover() */ public function testDumpOnlyAfterGeneratedAutoDiscoverWsdl() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Cannot dump autodiscovered contents'); $server->dump(false); @@ -817,7 +773,7 @@ public function testDumpOnlyAfterGeneratedAutoDiscoverWsdl() */ public function testXmlOnlyAfterGeneratedAutoDiscoverWsdl() { - $server = new AutoDiscover(); + $server = $this->createAutodiscoverService(); $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Cannot return autodiscovered contents'); $server->toXml(); @@ -828,7 +784,8 @@ public function testXmlOnlyAfterGeneratedAutoDiscoverWsdl() */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex() { - $autodiscover = new AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex); + $autodiscover = $this->createAutodiscoverService(); + $autodiscover->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex); $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyService'); $wsdl = $autodiscover->toXml(); @@ -842,7 +799,8 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayC */ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence() { - $autodiscover = new AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence); + $autodiscover = $this->createAutodiscoverService(); + $autodiscover->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence); $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyServiceSequence'); $wsdl = $autodiscover->toXml(); @@ -872,7 +830,7 @@ public function testAmpersandInUrlIsCorrectlyEncoded() */ public function testNoReturnIsOneWayCallInSetClass() { - $autodiscover = new AutoDiscover(); + $autodiscover = $this->createAutodiscoverService(); $autodiscover->setClass('\ZendTest\Soap\TestAsset\NoReturnType'); $wsdl = $autodiscover->toXml(); @@ -887,7 +845,7 @@ public function testNoReturnIsOneWayCallInSetClass() */ public function testNoReturnIsOneWayCallInAddFunction() { - $autodiscover = new AutoDiscover(); + $autodiscover = $this->createAutodiscoverService(); $autodiscover->addFunction('\ZendTest\Soap\TestAsset\OneWay'); $wsdl = $autodiscover->toXml(); @@ -903,7 +861,8 @@ public function testNoReturnIsOneWayCallInAddFunction() */ public function testRecursiveWsdlDependencies() { - $autodiscover = new AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex); + $autodiscover = $this->createAutodiscoverService(); + $autodiscover->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence); $autodiscover->setClass('\ZendTest\Soap\TestAsset\Recursion'); $wsdl = $autodiscover->toXml(); From 5540089555b9fed5307772bf527b9610f51baf5b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 5 Dec 2011 17:22:40 +0100 Subject: [PATCH 067/123] [SOAP] Remove Zend\Server\Server interface from Zend\Soap\Autodiscover. It did never make any sense. Renamed Autodiscover#handle() to Autodiscover#generate() --- src/AutoDiscover.php | 52 ++---------------------------- test/AutoDiscoverTest.php | 66 +++++++++------------------------------ 2 files changed, 17 insertions(+), 101 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 49a4120d..57c73dd9 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -35,7 +35,7 @@ * @package Zend_Soap * @subpackage AutoDiscover */ -class AutoDiscover implements \Zend\Server\Server +class AutoDiscover { /** * @var \Zend\Soap\Wsdl @@ -428,23 +428,9 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } /** - * Action to take when an error occurs - * - * @param string $fault - * @param string|int $code - * @throws \Zend\Soap\Exception\UnexpectedValueException - */ - public function fault($fault = null, $code = null) - { - throw new Exception\UnexpectedValueException('Function has no use in AutoDiscover.'); - } - - /** - * Handle the Request - * - * @param string $request A non-standard request - Not Used + * Generate the WSDL file from the configured input. */ - public function handle($request = false) + public function generate() { if (!headers_sent()) { header('Content-Type: text/xml'); @@ -483,38 +469,6 @@ public function toXml() } } - /** - * Return an array of functions in the WSDL - * - * @return array - */ - public function getFunctions() - { - return $this->_functions; - } - - /** - * Load Functions - * - * @param unknown_type $definition - * @throws \Zend\Soap\Exception\RuntimeException - */ - public function loadFunctions($definition) - { - throw new Exception\RuntimeException('Function has no use in AutoDiscover.'); - } - - /** - * Set Persistance - * - * @param int $mode - * @throws \Zend\Soap\Exception\RuntimeException - */ - public function setPersistence($mode) - { - throw new Exception\RuntimeException('Function has no use in AutoDiscover.'); - } - /** * Returns an XSD Type for the given PHP type * diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 1357a2be..208b9b5b 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -79,7 +79,7 @@ function testSetClass() $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $wsdl = '' @@ -170,7 +170,7 @@ function testSetClassWithDifferentStyles() $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $wsdl = '' @@ -328,7 +328,7 @@ function testSetClassWithResponseReturnPartCompabilityMode() $server->setClass('\ZendTest\Soap\TestAsset\Test'); $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); @@ -349,7 +349,7 @@ function testAddFunctionSimple() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); @@ -394,7 +394,7 @@ function testAddFunctionSimpleWithDifferentStyle() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); @@ -445,7 +445,7 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); @@ -476,7 +476,7 @@ function testAddFunctionMultiple() $dom = new \DOMDocument(); ob_start(); - $server->handle(); + $server->generate(); $dom->loadXML(ob_get_clean()); $dom->save(__DIR__.'/TestAsset/addfunction2.wsdl'); @@ -578,7 +578,7 @@ public function testChangeWsdlUriInConstructor() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -597,7 +597,7 @@ public function testChangeWsdlUriViaSetUri() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -624,7 +624,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -633,7 +633,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible() $server->setUri("http://example2.com/service2.php"); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -654,50 +654,12 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() $server->setClass('\ZendTest\Soap\TestAsset\TestFixingMultiplePrototypes'); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertEquals(1, substr_count($wsdlOutput, '')); $this->assertEquals(1, substr_count($wsdlOutput, '')); } - - public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnBadPersistence() - { - $server = $this->createAutodiscoverService(); - - $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Function has no use in AutoDiscover'); - $server->setPersistence("bogus"); - } - - - public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnFault() - { - $server = $this->createAutodiscoverService(); - - $this->setExpectedException('Zend\Soap\Exception\UnexpectedValueException', 'Function has no use in AutoDiscover'); - $server->fault(); - } - - public function testUnusedFunctionsOfAutoDiscoverThrowExceptionOnLoadFunctionsCall() - { - $server = $this->createAutodiscoverService(); - - $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Function has no use in AutoDiscover'); - $server->loadFunctions("bogus"); - } - - public function testGetFunctions() - { - $server = $this->createAutodiscoverService(); - $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - $server->setClass('\ZendTest\Soap\TestAsset\Test'); - - $functions = $server->getFunctions(); - $this->assertEquals( - array('ZendTest\Soap\TestAsset\TestFunc', 'testFunc1', 'testFunc2', 'testFunc3', 'testFunc4'), - $functions - ); - } /** * @group ZF-4937 @@ -709,7 +671,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() $server->setClass('\ZendTest\Soap\TestAsset\AutoDiscoverTestClass2'); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertEquals(1, @@ -739,7 +701,7 @@ public function testDumpOrXmlOfAutoDiscover() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); ob_start(); - $server->handle(); + $server->generate(); $wsdlOutput = ob_get_clean(); $this->assertEquals( From e554f34d81d920b64cd3b0dbdb154ccf7f4f7a3b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 5 Dec 2011 18:04:18 +0100 Subject: [PATCH 068/123] [SOAP] Savepoint in Autodiscover refactoring to sanity --- src/AutoDiscover.php | 157 +++++++++++++++++++++++-------------- test/AutoDiscoverTest.php | 159 ++++++++++---------------------------- 2 files changed, 140 insertions(+), 176 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 57c73dd9..67ca85e1 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -37,6 +37,11 @@ */ class AutoDiscover { + /** + * @var string + */ + protected $_serviceName; + /** * @var \Zend\Soap\Wsdl */ @@ -48,9 +53,18 @@ class AutoDiscover protected $_reflection = null; /** + * Service function names + * * @var array */ protected $_functions = array(); + + /** + * Service class name + * + * @var string + */ + protected $_class; /** * @var boolean @@ -107,6 +121,40 @@ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=n $this->setWsdlClass($wsdlClass); } } + + /** + * Set service name + * + * @param string $serviceName + * @return AutoDiscover + */ + public function setServiceName($serviceName) + { + $this->_serviceName = $serviceName; + return $this; + } + + /** + * Get service name + * + * @return string + */ + public function getServiceName() + { + if (!$this->_serviceName) { + if ($this->_class) { + return $this->_reflection->reflectClass($this->_class) + ->getShortName(); + } else { + throw new Exception\RuntimeException( + "No service name given. Call Autodiscover#setServiceName()." + ); + } + } + + return $this->_serviceName; + } + /** * Set the location at which the WSDL file will be availabe. @@ -236,28 +284,45 @@ public function setComplexTypeStrategy(ComplexTypeStrategy $strategy) * Set the Class the SOAP server will use * * @param string $class Class Name - * @param string $namespace Class Namspace - Not Used - * @param array $argv Arguments to instantiate the class - Not Used * @return \Zend\Soap\AutoDiscover */ - public function setClass($class, $namespace = '', $argv = null) + public function setClass($class) + { + $this->_class = $class; + return $this; + } + + /** + * Add a Single or Multiple Functions to the WSDL + * + * @param string $function Function Name + * @return \Zend\Soap\AutoDiscover + */ + public function addFunction($function) { + $this->_functions[] = $function; + return $this; + } + + protected function generateClass() + { + $class = $this->_class; $uri = $this->getUri(); - $translatedClassName = Wsdl::translateType($class); + $serviceName = $this->getServiceName(); - $wsdl = new $this->_wsdlClass($translatedClassName, $uri, $this->_strategy); + $wsdl = new $this->_wsdlClass($serviceName, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); - $port = $wsdl->addPortType($translatedClassName . 'Port'); - $binding = $wsdl->addBinding($translatedClassName . 'Binding', 'tns:' . $translatedClassName . 'Port'); + $port = $wsdl->addPortType($serviceName . 'Port'); + $binding = $wsdl->addBinding($serviceName . 'Binding', 'tns:' . $serviceName . 'Port'); $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); - $wsdl->addService($translatedClassName . 'Service', - $translatedClassName . 'Port', - 'tns:' . $translatedClassName . 'Binding', $uri); + $wsdl->addService($serviceName . 'Service', + $serviceName . 'Port', + 'tns:' . $serviceName . 'Binding', $uri); foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } @@ -265,44 +330,24 @@ public function setClass($class, $namespace = '', $argv = null) return $this; } - - /** - * Add a Single or Multiple Functions to the WSDL - * - * @param string $function Function Name - * @param string $namespace Function namespace - Not Used - * @return \Zend\Soap\AutoDiscover - */ - public function addFunction($function, $namespace = '') + + protected function generateFunctions() { - static $port; - static $operation; - static $binding; - - if (!is_array($function)) { - $function = (array) $function; - } - $uri = $this->getUri(); - if (!($this->_wsdl instanceof Wsdl)) { - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; - $wsdl = new Wsdl($name, $uri, $this->_strategy); + $serviceName = $this->getServiceName(); + $wsdl = new Wsdl($serviceName, $uri, $this->_strategy); - // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) - $wsdl->addSchemaTypeSection(); + // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) + $wsdl->addSchemaTypeSection(); - $port = $wsdl->addPortType($name . 'Port'); - $binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port'); + $port = $wsdl->addPortType($serviceName . 'Port'); + $binding = $wsdl->addBinding($serviceName . 'Binding', 'tns:' .$serviceName. 'Port'); - $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); - $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri); - } else { - $wsdl = $this->_wsdl; - } + $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); + $wsdl->addService($serviceName . 'Service', $serviceName . 'Port', 'tns:' . $serviceName . 'Binding', $uri); - foreach ($function as $func) { + foreach ($this->_functions as $func) { $method = $this->_reflection->reflectFunction($func); $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } @@ -422,20 +467,26 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle); } $wsdl->addSoapOperation($operation, $uri . '#' . $functionName); - - // Add the function name to the list - $this->_functions[] = $function->getName(); } /** * Generate the WSDL file from the configured input. + * + * @return Zend_Wsdl */ public function generate() { - if (!headers_sent()) { - header('Content-Type: text/xml'); + if ($this->_class && $this->_functions) { + throw new Exception\RuntimeException("Can either dump functions or a class as a service, not both."); + } + + if ($this->_class) { + $this->generateClass(); + } else { + $this->generateFunctions(); } - $this->_wsdl->dump(); + + return $this->_wsdl; } /** @@ -447,11 +498,7 @@ public function generate() */ public function dump($filename) { - if($this->_wsdl !== null) { - return $this->_wsdl->dump($filename); - } else { - throw new Exception\RuntimeException('Cannot dump autodiscovered contents, WSDL file has not been generated yet.'); - } + return $this->generate()->dump($filename); } /** @@ -462,11 +509,7 @@ public function dump($filename) */ public function toXml() { - if($this->_wsdl !== null) { - return $this->_wsdl->toXml(); - } else { - throw new Exception\RuntimeException('Cannot return autodiscovered contents, WSDL file has not been generated yet.'); - } + return $this->generate()->toXml(); } /** diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 208b9b5b..0e0fda7c 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -61,6 +61,7 @@ protected function createAutodiscoverService() { $server = new AutoDiscover(); $server->setUri('http://localhost/my_script.php'); + $server->setServiceName('TestService'); return $server; } @@ -77,10 +78,7 @@ function testSetClass() $server = $this->createAutodiscoverService(); $server->setClass('\ZendTest\Soap\TestAsset\Test'); - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + $dom = $server->generate()->toDomDocument(); $wsdl = '' . '' . '' . '' . '' - . '' + . '' . '' . 'Test Function 1' . '' @@ -115,7 +113,7 @@ function testSetClass() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -138,8 +136,8 @@ function testSetClass() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -168,10 +166,7 @@ function testSetClassWithDifferentStyles() $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->setClass('\ZendTest\Soap\TestAsset\Test'); - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + $dom = $server->generate()->toDomDocument(); $wsdl = '' . '' . '' . '' @@ -235,7 +230,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . 'Test Function 1' . '' @@ -256,7 +251,7 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -279,8 +274,8 @@ function testSetClassWithDifferentStyles() . '' . '' . '' - . '' - . '' + . '' + . '' . '' . '' . '' @@ -326,10 +321,7 @@ function testSetClassWithResponseReturnPartCompabilityMode() $server = $this->createAutodiscoverService(); $server->setClass('\ZendTest\Soap\TestAsset\Test'); - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); $this->assertContains('sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); @@ -347,14 +339,12 @@ function testAddFunctionSimple() $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + + $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; + + $name = "TestService"; $wsdl = ''. ''. @@ -392,14 +382,12 @@ function testAddFunctionSimpleWithDifferentStyle() $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + + $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; + + $name = "TestService"; $wsdl = ''. ''. @@ -443,14 +431,12 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + + $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; + + $name = "TestService"; $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()); $this->assertContains('', $wsdl); @@ -473,15 +459,11 @@ function testAddFunctionMultiple() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc6'); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc7'); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc9'); - - $dom = new \DOMDocument(); - ob_start(); - $server->generate(); - $dom->loadXML(ob_get_clean()); + + $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction2.wsdl'); - $parts = explode('.', basename($_SERVER['SCRIPT_NAME'])); - $name = $parts[0]; + $name = "TestService"; $wsdl = ''. ''. @@ -562,8 +544,6 @@ function testAddFunctionMultiple() $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(__DIR__.'/TestAsset/addfunction2.wsdl'); } @@ -575,11 +555,10 @@ public function testChangeWsdlUriInConstructor() $scriptUri = 'http://localhost/my_script.php'; $server = new AutoDiscover(null, "http://example.com/service.php"); + $server->setServiceName("TestService"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); + + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertContains("http://example.com/service.php", $wsdlOutput); @@ -595,10 +574,8 @@ public function testChangeWsdlUriViaSetUri() $server = $this->createAutodiscoverService(); $server->setUri("http://example.com/service.php"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); + + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertContains("http://example.com/service.php", $wsdlOutput); @@ -622,19 +599,15 @@ public function testChangingWsdlUriAfterGenerationIsPossible() $server = $this->createAutodiscoverService(); $server->setUri("http://example.com/service.php"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); + + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertContains("http://example.com/service.php", $wsdlOutput); $server->setUri("http://example2.com/service2.php"); - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); $this->assertNotContains("http://example.com/service.php", $wsdlOutput); @@ -653,9 +626,7 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() $server = $this->createAutodiscoverService(); $server->setClass('\ZendTest\Soap\TestAsset\TestFixingMultiplePrototypes'); - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); + $wsdlOutput = $server->toXml(); $this->assertEquals(1, substr_count($wsdlOutput, '')); $this->assertEquals(1, substr_count($wsdlOutput, '')); @@ -670,9 +641,7 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() $server->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex); $server->setClass('\ZendTest\Soap\TestAsset\AutoDiscoverTestClass2'); - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); + $wsdlOutput = $server->toXml(); $this->assertEquals(1, substr_count($wsdlOutput, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.AutoDiscoverTestClass1[]"'), @@ -692,55 +661,6 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() ); } - /** - * @group ZF-5330 - */ - public function testDumpOrXmlOfAutoDiscover() - { - $server = $this->createAutodiscoverService(); - $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - - ob_start(); - $server->generate(); - $wsdlOutput = ob_get_clean(); - - $this->assertEquals( - $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), - $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) - ); - - ob_start(); - $server->dump(false); - $wsdlOutput = ob_get_clean(); - - $this->assertEquals( - $this->sanitizeWsdlXmlOutputForOsCompability($wsdlOutput), - $this->sanitizeWsdlXmlOutputForOsCompability($server->toXml()) - ); - } - - /** - * @group ZF-5330 - */ - public function testDumpOnlyAfterGeneratedAutoDiscoverWsdl() - { - $server = $this->createAutodiscoverService(); - - $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Cannot dump autodiscovered contents'); - $server->dump(false); - } - - /** - * @group ZF-5330 - */ - public function testXmlOnlyAfterGeneratedAutoDiscoverWsdl() - { - $server = $this->createAutodiscoverService(); - - $this->setExpectedException('Zend\Soap\Exception\RuntimeException', 'Cannot return autodiscovered contents'); - $server->toXml(); - } - /** * @group ZF-5604 */ @@ -808,6 +728,7 @@ public function testNoReturnIsOneWayCallInSetClass() public function testNoReturnIsOneWayCallInAddFunction() { $autodiscover = $this->createAutodiscoverService(); + $autodiscover->setServiceName('TestService'); $autodiscover->addFunction('\ZendTest\Soap\TestAsset\OneWay'); $wsdl = $autodiscover->toXml(); From ee51226dad87a5d0653bc51871616434e231b098 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 7 Dec 2011 22:21:39 +0100 Subject: [PATCH 069/123] [SOAP] Came across very stupid libxml bug. Have to reload xml to actually get it to validate. --- src/AutoDiscover.php | 9 +++++---- test/AutoDiscoverTest.php | 24 ++++++++++++++++++++---- test/schemas/wsdl.xsd | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 67ca85e1..926ae762 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -456,15 +456,16 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } // When using the RPC style, make sure the operation style includes a 'namespace' attribute (WS-I Basic Profile 1.1 R2717) - if ($this->_bindingStyle['style'] == 'rpc' && !isset($this->_operationBodyStyle['namespace'])) { - $this->_operationBodyStyle['namespace'] = ''.$uri; + $operationBodyStyle = $this->_operationBodyStyle; + if ($this->_bindingStyle['style'] == 'rpc' && !isset($operationBodyStyle['namespace'])) { + $operationBodyStyle['namespace'] = ''.$uri; } // Add the binding operation if($isOneWayMessage == false) { - $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle, $this->_operationBodyStyle); + $operation = $wsdl->addBindingOperation($binding, $functionName, $operationBodyStyle, $operationBodyStyle); } else { - $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle); + $operation = $wsdl->addBindingOperation($binding, $functionName, $operationBodyStyle); } $wsdl->addSoapOperation($operation, $uri . '#' . $functionName); } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 0e0fda7c..e8c42f6c 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -151,10 +151,14 @@ function testSetClass() . '' . ''; - $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + + $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); + + $dom = new \DOMDocument(); + $dom->load(__DIR__.'/TestAsset/setclass.wsdl'); + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(__DIR__.'/TestAsset/setclass.wsdl'); } @@ -306,6 +310,10 @@ function testSetClassWithDifferentStyles() . ''; $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); + + $dom = new \DOMDocument(); + $dom->load(__DIR__.'/TestAsset/setclass.wsdl'); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -342,7 +350,8 @@ function testAddFunctionSimple() $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - + $dom = new \DOMDocument(); + $dom->load(__DIR__.'/TestAsset/addfunction.wsdl'); $name = "TestService"; @@ -416,6 +425,10 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''; + + $dom = new \DOMDocument(); + $dom->load(__DIR__.'/TestAsset/addfunction.wsdl'); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); @@ -434,7 +447,8 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - + $dom = new \DOMDocument(); + $dom->load(__DIR__.'/TestAsset/addfunction.wsdl'); $name = "TestService"; @@ -462,6 +476,8 @@ function testAddFunctionMultiple() $dom = $server->generate()->toDomDocument(); $dom->save(__DIR__.'/TestAsset/addfunction2.wsdl'); + $dom = new \DOMDocument(); + $dom->load(__DIR__.'/TestAsset/addfunction2.wsdl'); $name = "TestService"; diff --git a/test/schemas/wsdl.xsd b/test/schemas/wsdl.xsd index 14b5bef3..0546b338 100644 --- a/test/schemas/wsdl.xsd +++ b/test/schemas/wsdl.xsd @@ -42,6 +42,7 @@ No other rights are granted by implication, estoppel or otherwise. + This type is extended by component types to allow them to be documented @@ -52,6 +53,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -62,6 +64,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -72,6 +75,7 @@ No other rights are granted by implication, estoppel or otherwise. This type is extended by component types to allow elements from other namespaces to be added. + @@ -81,6 +85,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -90,6 +95,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -99,6 +105,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -109,6 +116,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -118,6 +126,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -136,6 +145,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -146,6 +156,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -158,6 +169,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -169,6 +181,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -180,6 +193,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -191,6 +205,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -201,6 +216,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -220,6 +236,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -239,6 +256,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -249,6 +267,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -259,6 +278,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -269,6 +289,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -278,6 +299,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -288,6 +310,7 @@ No other rights are granted by implication, estoppel or otherwise. + @@ -298,6 +321,7 @@ No other rights are granted by implication, estoppel or otherwise. + From fefecf4add8a7fa89b03cbaeb5977f8de9d8a348 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 7 Dec 2011 22:29:20 +0100 Subject: [PATCH 070/123] [SOAP] Refactored Validation of WSDL against XSD Schema in tests --- test/AutoDiscoverTest.php | 77 +++++++++++++++------------------------ 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index e8c42f6c..f06bf03f 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -71,6 +71,27 @@ protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); return $xmlstring; } + + /** + * Assertion to validate DOMDocument is a valid WSDL file. + * + * @param \DOMDocument $dom + */ + protected function assertValidWSDL(\DOMDocument $dom) + { + // this code is necessary to support some libxml stupidities. + $file = __DIR__.'/TestAsset/validate.wsdl'; + if (file_exists($file)) { + unlink($file); + } + + $dom->save($file); + $dom = new \DOMDocument(); + $dom->load($file); + + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); + unlink($file); + } function testSetClass() { @@ -151,15 +172,8 @@ function testSetClass() . '' . ''; - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); - - $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); - - $dom = new \DOMDocument(); - $dom->load(__DIR__.'/TestAsset/setclass.wsdl'); - - $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - unlink(__DIR__.'/TestAsset/setclass.wsdl'); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertValidWSDL($dom); } function testSetClassWithDifferentStyles() @@ -308,16 +322,9 @@ function testSetClassWithDifferentStyles() . '' . '' . ''; - - $dom->save(__DIR__.'/TestAsset/setclass.wsdl'); - - $dom = new \DOMDocument(); - $dom->load(__DIR__.'/TestAsset/setclass.wsdl'); $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); - $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(__DIR__.'/TestAsset/setclass.wsdl'); + $this->assertValidWSDL($dom); } /** @@ -349,10 +356,7 @@ function testAddFunctionSimple() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = $server->generate()->toDomDocument(); - $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - $dom = new \DOMDocument(); - $dom->load(__DIR__.'/TestAsset/addfunction.wsdl'); - + $name = "TestService"; $wsdl = ''. @@ -378,9 +382,7 @@ function testAddFunctionSimple() ''. ''; $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); - $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(__DIR__.'/TestAsset/addfunction.wsdl'); + $this->assertValidWSDL($dom); } function testAddFunctionSimpleWithDifferentStyle() @@ -393,11 +395,8 @@ function testAddFunctionSimpleWithDifferentStyle() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = $server->generate()->toDomDocument(); - $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - $name = "TestService"; - $wsdl = ''. ''. ''. @@ -424,15 +423,9 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''; - - $dom = new \DOMDocument(); - $dom->load(__DIR__.'/TestAsset/addfunction.wsdl'); - + ''; $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); - $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(__DIR__.'/TestAsset/addfunction.wsdl'); + $this->assertValidWSDL($dom); } /** @@ -446,18 +439,13 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); $dom = $server->generate()->toDomDocument(); - $dom->save(__DIR__.'/TestAsset/addfunction.wsdl'); - $dom = new \DOMDocument(); - $dom->load(__DIR__.'/TestAsset/addfunction.wsdl'); $name = "TestService"; $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()); $this->assertContains('', $wsdl); $this->assertNotContains('assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(__DIR__.'/TestAsset/addfunction.wsdl'); + $this->assertValidWSDL($dom); } function testAddFunctionMultiple() @@ -475,9 +463,6 @@ function testAddFunctionMultiple() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc9'); $dom = $server->generate()->toDomDocument(); - $dom->save(__DIR__.'/TestAsset/addfunction2.wsdl'); - $dom = new \DOMDocument(); - $dom->load(__DIR__.'/TestAsset/addfunction2.wsdl'); $name = "TestService"; @@ -558,9 +543,7 @@ function testAddFunctionMultiple() ''. ''; $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); - $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); - - unlink(__DIR__.'/TestAsset/addfunction2.wsdl'); + $this->assertValidWSDL($dom); } /** From 4f2908eb5398a19c3c6e603fbc082c969f470211 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 7 Dec 2011 22:29:52 +0100 Subject: [PATCH 071/123] [SOAP] Remove $_SERVER haxoring, since that is removed --- test/AutoDiscoverTest.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index f06bf03f..4d85ca49 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -43,20 +43,7 @@ * @group Zend_Soap */ class AutoDiscoverTest extends \PHPUnit_Framework_TestCase -{ - public function setUp() - { - // This has to be done because some CLI setups don't have $_SERVER variables - // to simuulate that we have an actual webserver. - if(!isset($_SERVER) || !is_array($_SERVER)) { - $_SERVER = array(); - } - $_SERVER['HTTP_HOST'] = 'localhost'; - $_SERVER['REQUEST_URI'] = '/my_script.php?wsdl'; - $_SERVER['SCRIPT_NAME'] = '/my_script.php'; - $_SERVER['HTTPS'] = "off"; - } - +{ protected function createAutodiscoverService() { $server = new AutoDiscover(); From 99564a8e017dd8890b2733dc70320f6bd9680e21 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 7 Dec 2011 22:59:26 +0100 Subject: [PATCH 072/123] [SOAP] Remove Autodiscover::$_wsdl as its not necessary anymore --- src/AutoDiscover.php | 61 ++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 926ae762..4de97f44 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -41,11 +41,6 @@ class AutoDiscover * @var string */ protected $_serviceName; - - /** - * @var \Zend\Soap\Wsdl - */ - protected $_wsdl = null; /** * @var \Zend\Server\Reflection @@ -172,11 +167,6 @@ public function setUri($uri) } $this->_uri = $uri; - // change uri in WSDL file also if existant - if ($this->_wsdl instanceof Wsdl) { - $this->_wsdl->setUri($uri); - } - return $this; } @@ -273,9 +263,6 @@ public function setBindingStyle(array $bindingStyle=array()) public function setComplexTypeStrategy(ComplexTypeStrategy $strategy) { $this->_strategy = $strategy; - if($this->_wsdl instanceof Wsdl) { - $this->_wsdl->setComplexTypeStrategy($strategy); - } return $this; } @@ -304,7 +291,12 @@ public function addFunction($function) return $this; } - protected function generateClass() + /** + * Generate the WSDL for a service class. + * + * @return Zend\Soap\Wsdl + */ + protected function _generateClass() { $class = $this->_class; $uri = $this->getUri(); @@ -326,12 +318,16 @@ protected function generateClass() foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } - $this->_wsdl = $wsdl; - - return $this; + + return $wsdl; } - protected function generateFunctions() + /** + * Generate the WSDL for a set of functions. + * + * @return Zend\Soap\Wsdl + */ + protected function _generateFunctions() { $uri = $this->getUri(); @@ -347,13 +343,12 @@ protected function generateFunctions() $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); $wsdl->addService($serviceName . 'Service', $serviceName . 'Port', 'tns:' . $serviceName . 'Binding', $uri); - foreach ($this->_functions as $func) { + foreach (array_unique($this->_functions) as $func) { $method = $this->_reflection->reflectFunction($func); $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } - $this->_wsdl = $wsdl; - return $this; + return $wsdl; } /** @@ -482,12 +477,12 @@ public function generate() } if ($this->_class) { - $this->generateClass(); + $wsdl = $this->_generateClass(); } else { - $this->generateFunctions(); + $wsdl = $this->_generateFunctions(); } - return $this->_wsdl; + return $wsdl; } /** @@ -512,22 +507,4 @@ public function toXml() { return $this->generate()->toXml(); } - - /** - * Returns an XSD Type for the given PHP type - * - * @param string $type PHP Type to get the XSD type for - * @return string - */ - public function getType($type) - { - if (!($this->_wsdl instanceof Wsdl)) { - /** @todo Exception throwing may be more correct */ - - // WSDL is not defined yet, so we can't recognize type in context of current service - return ''; - } else { - return $this->_wsdl->getType($type); - } - } } From 4833e21e4aff57b1af56ee977d47ea3e6bf517ff Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 7 Dec 2011 23:07:04 +0100 Subject: [PATCH 073/123] [SOAP] Remove code-dupcliation in Autodiscover#_generateClass and #_generateFunctions --- src/AutoDiscover.php | 45 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 4de97f44..dd1025cf 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -298,28 +298,7 @@ public function addFunction($function) */ protected function _generateClass() { - $class = $this->_class; - $uri = $this->getUri(); - - $serviceName = $this->getServiceName(); - - $wsdl = new $this->_wsdlClass($serviceName, $uri, $this->_strategy); - - // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) - $wsdl->addSchemaTypeSection(); - - $port = $wsdl->addPortType($serviceName . 'Port'); - $binding = $wsdl->addBinding($serviceName . 'Binding', 'tns:' . $serviceName . 'Port'); - - $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); - $wsdl->addService($serviceName . 'Service', - $serviceName . 'Port', - 'tns:' . $serviceName . 'Binding', $uri); - foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) { - $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); - } - - return $wsdl; + return $this->_generateWsdl($this->_reflection->reflectClass($this->_class)->getMethods()); } /** @@ -328,11 +307,26 @@ protected function _generateClass() * @return Zend\Soap\Wsdl */ protected function _generateFunctions() + { + $methods = array(); + foreach (array_unique($this->_functions) as $func) { + $methods[] = $this->_reflection->reflectFunction($func); + } + + return $this->_generateWsdl($methods); + } + + /** + * Generate the WSDL for a set of reflection method instances. + * + * @return Zend\Soap\Wsdl + */ + protected function _generateWsdl(array $reflectionMethods) { $uri = $this->getUri(); $serviceName = $this->getServiceName(); - $wsdl = new Wsdl($serviceName, $uri, $this->_strategy); + $wsdl = new $this->_wsdlClass($serviceName, $uri, $this->_strategy); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); @@ -343,8 +337,7 @@ protected function _generateFunctions() $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']); $wsdl->addService($serviceName . 'Service', $serviceName . 'Port', 'tns:' . $serviceName . 'Binding', $uri); - foreach (array_unique($this->_functions) as $func) { - $method = $this->_reflection->reflectFunction($func); + foreach ($reflectionMethods as $method) { $this->_addFunctionToWsdl($method, $wsdl, $port, $binding); } @@ -489,7 +482,7 @@ public function generate() * Proxy to WSDL dump function * * @param string $filename - * @return boolean + * @return bool * @throws \Zend\Soap\Exception\RuntimeException */ public function dump($filename) From 77c68250cc1f166b92ddc57179170fdfa7b3c462 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 7 Dec 2011 23:55:20 +0100 Subject: [PATCH 074/123] [SOAP] Extract interesting discovery code into protected methods. Cleaned up code --- src/AutoDiscover.php | 77 +++++++++++++++++++++++++++++++++++++------- test/WsdlTest.php | 2 +- 2 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index dd1025cf..15d44d89 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -26,7 +26,11 @@ use Zend\Uri, Zend\Soap\Wsdl, - Zend\Soap\Wsdl\ComplexTypeStrategy; + Zend\Soap\Wsdl\ComplexTypeStrategy, + Zend\Server\Reflection\AbstractFunction, + Zend\Server\Reflection, + Zend\Server\Reflection\Prototype, + Zend\Server\Reflection\ReflectionParameter; /** * \Zend\Soap\AutoDiscover @@ -103,7 +107,7 @@ class AutoDiscover */ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=null, $wsdlClass=null) { - $this->_reflection = new \Zend\Server\Reflection(); + $this->_reflection = new Reflection(); if ($strategy !== null) { $this->setComplexTypeStrategy($strategy); } @@ -343,6 +347,60 @@ protected function _generateWsdl(array $reflectionMethods) return $wsdl; } + + /** + * Get the function parameters php type. + * + * Default implementation assumes the default param doc-block tag. + * + * @param ReflectionParameter $param + * @return string + */ + protected function _getFunctionParameterType(ReflectionParameter $param) + { + return $param->getType(); + } + + /** + * Get the functions return php type. + * + * Default implementation assumes the value of the return doc-block tag. + * + * @param AbstractFunction $function + * @param Prototype $prototype + * @return type + */ + protected function _getFunctionReturnType(AbstractFunction $function, Prototype $prototype) + { + return $prototype->getReturnType(); + } + + /** + * Detect if the function is a one-way or two-way operation. + * + * Default implementation assumes one-way, when return value is "void". + * + * @param AbstractFunction $function + * @param Prototype $prototype + * @return type + */ + protected function _isFunctionOneWay(AbstractFunction $function, Prototype $prototype) + { + return $prototype->getReturnType() == 'void'; + } + + /** + * Detect the functions documentation. + * + * Default implementation uses docblock description. + * + * @param AbstractFunction $function + * @return type + */ + protected function _getFunctionDocumentation(AbstractFunction $function) + { + return $function->getDescription(); + } /** * Add a function to the WSDL document. @@ -381,7 +439,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) foreach ($prototype->getParameters() as $param) { $sequenceElement = array( 'name' => $param->getName(), - 'type' => $wsdl->getType($param->getType()) + 'type' => $wsdl->getType($this->_getFunctionParameterType($param)) ); if ($param->isOptional()) { $sequenceElement['nillable'] = 'true'; @@ -397,15 +455,12 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } else { // RPC style: add each parameter as a typed part foreach ($prototype->getParameters() as $param) { - $args[$param->getName()] = array('type' => $wsdl->getType($param->getType())); + $args[$param->getName()] = array('type' => $wsdl->getType($this->_getFunctionParameterType($param))); } } $wsdl->addMessage($functionName . 'In', $args); - $isOneWayMessage = false; - if($prototype->getReturnType() == "void") { - $isOneWayMessage = true; - } + $isOneWayMessage = $this->_isFunctionOneWay($function, $prototype); if($isOneWayMessage == false) { // Add the output message (return value) @@ -416,7 +471,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) if ($prototype->getReturnType() != "void") { $sequence[] = array( 'name' => $functionName . 'Result', - 'type' => $wsdl->getType($prototype->getReturnType()) + 'type' => $wsdl->getType($this->_getFunctionReturnType($function, $prototype)) ); } $element = array( @@ -427,7 +482,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) $args['parameters'] = array('element' => $wsdl->addElement($element)); } else if ($prototype->getReturnType() != "void") { // RPC style: add the return value as a typed part - $args['return'] = array('type' => $wsdl->getType($prototype->getReturnType())); + $args['return'] = array('type' => $wsdl->getType($this->_getFunctionReturnType($function, $prototype))); } $wsdl->addMessage($functionName . 'Out', $args); } @@ -438,7 +493,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } else { $portOperation = $wsdl->addPortOperation($port, $functionName, 'tns:' . $functionName . 'In', false); } - $desc = $function->getDescription(); + $desc = $this->_getFunctionDocumentation($function); if (strlen($desc) > 0) { $wsdl->addDocumentation($portOperation, $desc); } diff --git a/test/WsdlTest.php b/test/WsdlTest.php index 7da1503e..6688e4c0 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -550,7 +550,7 @@ function testGetComplexTypeBasedOnStrategiesStringNames() $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof ComplexTypeStrategy\DefaultComplexType); $wsdl2 = new Wsdl('MyService', 'http://localhost/MyService.php', new \Zend\Soap\Wsdl\ComplexTypeStrategy\AnyType); - $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); + $this->assertEquals('xsd:anyType', $wsdl2->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof ComplexTypeStrategy\AnyType); } From cf366581e689c37ee57ab99a1611e118659edf9a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 8 Dec 2011 00:10:31 +0100 Subject: [PATCH 075/123] [SOAP] TranslateType Refactoring, savepoint for going to shortnames instead of longnames by default. --- src/AutoDiscover.php | 2 +- src/Wsdl.php | 39 +++++++++++++++++-- .../ArrayOfTypeComplex.php | 4 +- .../ArrayOfTypeSequence.php | 2 +- .../DefaultComplexType.php | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 15d44d89..f0a7ef66 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -429,7 +429,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) throw new Exception\InvalidArgumentException("No prototypes could be found for the '" . $function->getName() . "' function"); } - $functionName = Wsdl::translateType($function->getName()); + $functionName = $wsdl->translateType($function->getName()); // Add the input message (parameters) $args = array(); diff --git a/src/Wsdl.php b/src/Wsdl.php index 51795736..9952c116 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -68,7 +68,13 @@ class Wsdl * Strategy for detection of complex types */ protected $_strategy = null; - + + /** + * Map of PHP Class names to WSDL QNames. + * + * @var array + */ + protected $_classMap = array(); /** * Constructor @@ -77,12 +83,13 @@ class Wsdl * @param string|Uri $uri URI where the WSDL will be available * @param \Zend\Soap\Wsdl\ComplexTypeStrategy $strategy */ - public function __construct($name, $uri, ComplexTypeStrategy $strategy = null) + public function __construct($name, $uri, ComplexTypeStrategy $strategy = null, array $classMap = array()) { if ($uri instanceof Uri) { $uri = $uri->toString(); } $this->_uri = $uri; + $this->_classMap = $classMap; /** * @todo change DomDocument object creation from cparsing to constructing using API @@ -105,7 +112,25 @@ public function __construct($name, $uri, ComplexTypeStrategy $strategy = null) $this->setComplexTypeStrategy($strategy ?: new Wsdl\ComplexTypeStrategy\DefaultComplexType); } + + /** + * Get the class map of php to wsdl qname types. + * + * @return array + */ + public function getClassMap() + { + return $this->_classMap; + } + /** + * Set the class map of php to wsdl qname types. + */ + public function setClassMap($classMap) + { + $this->_classMap = $classMap; + } + /** * Set a new uri for this WSDL * @@ -568,11 +593,19 @@ public function addSchemaTypeSection() * @param string $type * @return string QName */ - public static function translateType($type) + public function translateType($type) { + if (isset($this->_classMap[$type])) { + return $this->_classMap[$type]; + } + if ($type[0] == '\\') { $type = substr($type, 1); } + + /*if ($pos = strrpos($type, '\\')) { + $type = substr($type, $pos+1); + }*/ return str_replace('\\', '.', $type); } diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php index 054ec856..4b421314 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php @@ -83,7 +83,7 @@ protected function _addArrayOfComplexType($singularType, $type) return $soapType; } - $xsdComplexTypeName = 'ArrayOf' . Wsdl::translateType($singularType); + $xsdComplexTypeName = 'ArrayOf' . $this->getContext()->translateType($singularType); $xsdComplexType = 'tns:' . $xsdComplexTypeName; // Register type here to avoid recursion @@ -109,7 +109,7 @@ protected function _addArrayOfComplexType($singularType, $type) $xsdAttribute = $dom->createElement('xsd:attribute'); $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType'); $xsdAttribute->setAttribute('wsdl:arrayType', - 'tns:' . Wsdl::translateType($singularType) . '[]'); + 'tns:' . $this->getContext()->translateType($singularType) . '[]'); $xsdRestriction->appendChild($xsdAttribute); $this->getContext()->getSchema()->appendChild($complexType); diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php index 652a06eb..d88e4ea6 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php @@ -81,7 +81,7 @@ protected function _getTypeBasedOnNestingLevel($singularType, $level) // This is not an Array anymore, return the xsd simple type return $this->getContext()->getType($singularType); } else { - return 'tns:' . str_repeat('ArrayOf', $level) . ucfirst(Wsdl::translateType($singularType)); + return 'tns:' . str_repeat('ArrayOf', $level) . ucfirst($this->getContext()->translateType($singularType)); } } diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index e1f25548..b48c9d1f 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -64,7 +64,7 @@ public function addComplexType($type) $dom = $this->getContext()->toDomDocument(); $class = new \ReflectionClass($type); - $soapTypeName = Soap\Wsdl::translateType($type); + $soapTypeName = $this->getContext()->translateType($type); $soapType = 'tns:' . $soapTypeName; // Register type here to avoid recursion From 05fc4bf117f42c3639eb8c451d65f4fa6f4b62cd Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 8 Dec 2011 10:29:34 +0100 Subject: [PATCH 076/123] [SOAP] By default only the shortname of a class is used for a complex type. You can override this by setting a class-map for PHP to WSDL type transformations. --- src/AutoDiscover.php | 103 ++++++----- src/Wsdl.php | 18 +- test/AutoDiscoverTest.php | 160 +++++++++--------- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 40 ++--- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 10 +- test/Wsdl/CompositeStrategyTest.php | 14 +- test/WsdlTest.php | 10 +- 7 files changed, 190 insertions(+), 165 deletions(-) mode change 100644 => 100755 src/AutoDiscover.php mode change 100644 => 100755 src/Wsdl.php mode change 100644 => 100755 test/AutoDiscoverTest.php mode change 100644 => 100755 test/Wsdl/ArrayOfTypeComplexStrategyTest.php mode change 100644 => 100755 test/Wsdl/ArrayOfTypeSequenceStrategyTest.php mode change 100644 => 100755 test/Wsdl/CompositeStrategyTest.php mode change 100644 => 100755 test/WsdlTest.php diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php old mode 100644 new mode 100755 index f0a7ef66..fa4999c1 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -53,15 +53,15 @@ class AutoDiscover /** * Service function names - * + * * @var array */ protected $_functions = array(); - + /** * Service class name - * - * @var string + * + * @var string */ protected $_class; @@ -98,6 +98,13 @@ class AutoDiscover */ protected $_wsdlClass = 'Zend\Soap\Wsdl'; + /** + * Class Map of PHP to WSDL types. + * + * @var array + */ + protected $_classMap = array(); + /** * Constructor * @@ -105,7 +112,7 @@ class AutoDiscover * @param string|Uri\Uri $endpointUri * @param string $wsdlClass */ - public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=null, $wsdlClass=null) + public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=null, $wsdlClass=null, array $classMap = array()) { $this->_reflection = new Reflection(); if ($strategy !== null) { @@ -120,10 +127,28 @@ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=n $this->setWsdlClass($wsdlClass); } } - + + /** + * Get the class map of php to wsdl qname types. + * + * @return array + */ + public function getClassMap() + { + return $this->_classMap; + } + + /** + * Set the class map of php to wsdl qname types. + */ + public function setClassMap($classMap) + { + $this->_classMap = $classMap; + } + /** * Set service name - * + * * @param string $serviceName * @return AutoDiscover */ @@ -132,10 +157,10 @@ public function setServiceName($serviceName) $this->_serviceName = $serviceName; return $this; } - + /** * Get service name - * + * * @return string */ public function getServiceName() @@ -150,10 +175,10 @@ public function getServiceName() ); } } - + return $this->_serviceName; } - + /** * Set the location at which the WSDL file will be availabe. @@ -187,7 +212,7 @@ public function getUri() if (is_string($this->_uri)) { $this->_uri = Uri\UriFactory::factory($this->_uri); } - + return $this->_uri; } @@ -294,20 +319,20 @@ public function addFunction($function) $this->_functions[] = $function; return $this; } - + /** * Generate the WSDL for a service class. - * + * * @return Zend\Soap\Wsdl */ protected function _generateClass() - { + { return $this->_generateWsdl($this->_reflection->reflectClass($this->_class)->getMethods()); } - + /** * Generate the WSDL for a set of functions. - * + * * @return Zend\Soap\Wsdl */ protected function _generateFunctions() @@ -316,13 +341,13 @@ protected function _generateFunctions() foreach (array_unique($this->_functions) as $func) { $methods[] = $this->_reflection->reflectFunction($func); } - + return $this->_generateWsdl($methods); } - + /** * Generate the WSDL for a set of reflection method instances. - * + * * @return Zend\Soap\Wsdl */ protected function _generateWsdl(array $reflectionMethods) @@ -330,7 +355,7 @@ protected function _generateWsdl(array $reflectionMethods) $uri = $this->getUri(); $serviceName = $this->getServiceName(); - $wsdl = new $this->_wsdlClass($serviceName, $uri, $this->_strategy); + $wsdl = new $this->_wsdlClass($serviceName, $uri, $this->_strategy, $this->_classMap); // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023) $wsdl->addSchemaTypeSection(); @@ -347,12 +372,12 @@ protected function _generateWsdl(array $reflectionMethods) return $wsdl; } - + /** * Get the function parameters php type. - * + * * Default implementation assumes the default param doc-block tag. - * + * * @param ReflectionParameter $param * @return string */ @@ -360,42 +385,42 @@ protected function _getFunctionParameterType(ReflectionParameter $param) { return $param->getType(); } - + /** * Get the functions return php type. - * + * * Default implementation assumes the value of the return doc-block tag. - * + * * @param AbstractFunction $function * @param Prototype $prototype - * @return type + * @return type */ protected function _getFunctionReturnType(AbstractFunction $function, Prototype $prototype) { return $prototype->getReturnType(); } - + /** * Detect if the function is a one-way or two-way operation. - * + * * Default implementation assumes one-way, when return value is "void". - * + * * @param AbstractFunction $function * @param Prototype $prototype - * @return type + * @return type */ protected function _isFunctionOneWay(AbstractFunction $function, Prototype $prototype) { return $prototype->getReturnType() == 'void'; } - + /** * Detect the functions documentation. - * + * * Default implementation uses docblock description. - * + * * @param AbstractFunction $function - * @return type + * @return type */ protected function _getFunctionDocumentation(AbstractFunction $function) { @@ -515,7 +540,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) /** * Generate the WSDL file from the configured input. - * + * * @return Zend_Wsdl */ public function generate() @@ -523,13 +548,13 @@ public function generate() if ($this->_class && $this->_functions) { throw new Exception\RuntimeException("Can either dump functions or a class as a service, not both."); } - + if ($this->_class) { $wsdl = $this->_generateClass(); } else { $wsdl = $this->_generateFunctions(); } - + return $wsdl; } diff --git a/src/Wsdl.php b/src/Wsdl.php old mode 100644 new mode 100755 index 9952c116..37b48104 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -68,10 +68,10 @@ class Wsdl * Strategy for detection of complex types */ protected $_strategy = null; - + /** * Map of PHP Class names to WSDL QNames. - * + * * @var array */ protected $_classMap = array(); @@ -112,10 +112,10 @@ public function __construct($name, $uri, ComplexTypeStrategy $strategy = null, a $this->setComplexTypeStrategy($strategy ?: new Wsdl\ComplexTypeStrategy\DefaultComplexType); } - + /** * Get the class map of php to wsdl qname types. - * + * * @return array */ public function getClassMap() @@ -130,7 +130,7 @@ public function setClassMap($classMap) { $this->_classMap = $classMap; } - + /** * Set a new uri for this WSDL * @@ -598,14 +598,14 @@ public function translateType($type) if (isset($this->_classMap[$type])) { return $this->_classMap[$type]; } - + if ($type[0] == '\\') { $type = substr($type, 1); } - - /*if ($pos = strrpos($type, '\\')) { + + if ($pos = strrpos($type, '\\')) { $type = substr($type, $pos+1); - }*/ + } return str_replace('\\', '.', $type); } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php old mode 100644 new mode 100755 index 4d85ca49..5ab1c7d0 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -43,7 +43,7 @@ * @group Zend_Soap */ class AutoDiscoverTest extends \PHPUnit_Framework_TestCase -{ +{ protected function createAutodiscoverService() { $server = new AutoDiscover(); @@ -58,11 +58,11 @@ protected function sanitizeWsdlXmlOutputForOsCompability($xmlstring) $xmlstring = preg_replace('/(>[\s]{1,}<)/', '', $xmlstring); return $xmlstring; } - + /** * Assertion to validate DOMDocument is a valid WSDL file. - * - * @param \DOMDocument $dom + * + * @param \DOMDocument $dom */ protected function assertValidWSDL(\DOMDocument $dom) { @@ -71,11 +71,11 @@ protected function assertValidWSDL(\DOMDocument $dom) if (file_exists($file)) { unlink($file); } - + $dom->save($file); $dom = new \DOMDocument(); $dom->load($file); - + $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate"); unlink($file); } @@ -159,7 +159,7 @@ function testSetClass() . '' . ''; - $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertValidWSDL($dom); } @@ -309,7 +309,7 @@ function testSetClassWithDifferentStyles() . '' . '' . ''; - + $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML())); $this->assertValidWSDL($dom); } @@ -341,7 +341,7 @@ function testAddFunctionSimple() $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - + $dom = $server->generate()->toDomDocument(); $name = "TestService"; @@ -350,12 +350,12 @@ function testAddFunctionSimple() ''. ''. ''. - 'Test Function'. + 'Test Function'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -365,8 +365,8 @@ function testAddFunctionSimple() ''. ''. ''. - ''. - ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertValidWSDL($dom); @@ -380,25 +380,25 @@ function testAddFunctionSimpleWithDifferentStyle() $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com')); $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com')); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - + $dom = $server->generate()->toDomDocument(); - + $name = "TestService"; $wsdl = ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - 'Test Function'. + 'Test Function'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -408,9 +408,9 @@ function testAddFunctionSimpleWithDifferentStyle() ''. ''. ''. - ''. - ''. - ''; + ''. + ''. + ''; $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated"); $this->assertValidWSDL($dom); } @@ -424,14 +424,14 @@ function testAddFunctionSimpleInReturnNameCompabilityMode() $server = $this->createAutodiscoverService(); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - + $dom = $server->generate()->toDomDocument(); - + $name = "TestService"; $wsdl = $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()); - $this->assertContains('', $wsdl); - $this->assertNotContains('assertContains('', $wsdl); + $this->assertNotContains('assertValidWSDL($dom); } @@ -448,7 +448,7 @@ function testAddFunctionMultiple() $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc6'); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc7'); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc9'); - + $dom = $server->generate()->toDomDocument(); $name = "TestService"; @@ -457,53 +457,53 @@ function testAddFunctionMultiple() ''. ''. ''. - 'Test Function'. - 'Test Function 2'. - 'Return false'. - 'Return true'. - 'Return integer'. - 'Return string'. - 'Return array'. - 'Multiple Args'. + 'Test Function'. + 'Test Function 2'. + 'Return false'. + 'Return true'. + 'Return integer'. + 'Return string'. + 'Return array'. + 'Multiple Args'. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. - ''. - ''. + ''. + ''. ''. ''. ''. @@ -513,21 +513,21 @@ function testAddFunctionMultiple() ''. ''. ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''; $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Generated WSDL did not match expected XML"); $this->assertValidWSDL($dom); @@ -543,7 +543,7 @@ public function testChangeWsdlUriInConstructor() $server = new AutoDiscover(null, "http://example.com/service.php"); $server->setServiceName("TestService"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -560,7 +560,7 @@ public function testChangeWsdlUriViaSetUri() $server = $this->createAutodiscoverService(); $server->setUri("http://example.com/service.php"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -570,7 +570,7 @@ public function testChangeWsdlUriViaSetUri() public function testSetNonStringNonZendUriUriThrowsException() { $server = $this->createAutodiscoverService(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'No uri given to'); $server->setUri(array("bogus")); } @@ -585,7 +585,7 @@ public function testChangingWsdlUriAfterGenerationIsPossible() $server = $this->createAutodiscoverService(); $server->setUri("http://example.com/service.php"); $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc'); - + $wsdlOutput = $server->toXml(); $this->assertNotContains($scriptUri, $wsdlOutput); @@ -617,7 +617,7 @@ public function testUsingClassWithMultipleMethodPrototypesProducesValidWsdl() $this->assertEquals(1, substr_count($wsdlOutput, '')); $this->assertEquals(1, substr_count($wsdlOutput, '')); } - + /** * @group ZF-4937 */ @@ -630,19 +630,19 @@ public function testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce() $wsdlOutput = $server->toXml(); $this->assertEquals(1, - substr_count($wsdlOutput, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.AutoDiscoverTestClass1[]"'), + substr_count($wsdlOutput, 'wsdl:arrayType="tns:AutoDiscoverTestClass1[]"'), 'wsdl:arrayType definition of TestClass1 has to occour once.' ); $this->assertEquals(1, - substr_count($wsdlOutput, ''), + substr_count($wsdlOutput, ''), '\ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 has to be defined once.' ); $this->assertEquals(1, - substr_count($wsdlOutput, ''), + substr_count($wsdlOutput, ''), '\ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 should be defined once.' ); $this->assertTrue( - substr_count($wsdlOutput, '') >= 1, + substr_count($wsdlOutput, '') >= 1, '\ZendTest\Soap\TestAsset\AutoDiscoverTestClass1 appears once or more than once in the message parts section.' ); } @@ -657,7 +657,7 @@ public function testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayC $autodiscover->setClass('\ZendTest\Soap\TestAsset\MyService'); $wsdl = $autodiscover->toXml(); - $this->assertEquals(1, substr_count($wsdl, '')); + $this->assertEquals(1, substr_count($wsdl, '')); $this->assertEquals(0, substr_count($wsdl, 'tns:My_Response[]')); } @@ -719,7 +719,7 @@ public function testNoReturnIsOneWayCallInAddFunction() $wsdl = $autodiscover->toXml(); $this->assertContains( - '@param string $message', + '@param string $message', $wsdl ); } @@ -742,7 +742,7 @@ public function testRecursiveWsdlDependencies() // - $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="ZendTest.Soap.TestAsset.Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:ZendTest.Soap.TestAsset.Recursion"]'; + $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:Recursion"]'; $this->assertWsdlPathExists($wsdl, $path); } diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php old mode 100644 new mode 100755 index 3624c724..e6ad8007 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -67,18 +67,18 @@ public function testAddComplexTypeOfNonExistingClassThrowsException() public function testArrayOfSimpleObject() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[]'); - $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexTest", $return); + $this->assertEquals("tns:ArrayOfComplexTest", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } @@ -86,7 +86,7 @@ public function testArrayOfSimpleObject() public function testThatOverridingStrategyIsReset() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTest[]'); - $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexTest", $return); + $this->assertEquals("tns:ArrayOfComplexTest", $return); // $this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplexStrategy); $wsdl = $this->wsdl->toXML(); @@ -98,18 +98,18 @@ public function testThatOverridingStrategyIsReset() public function testArrayOfComplexObjects() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectStructure[]'); - $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexObjectStructure", $return); + $this->assertEquals("tns:ArrayOfComplexObjectStructure", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } @@ -117,23 +117,23 @@ public function testArrayOfComplexObjects() public function testArrayOfObjectWithObject() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexObjectWithObjectStructure[]'); - $this->assertEquals("tns:ArrayOfZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure", $return); + $this->assertEquals("tns:ArrayOfComplexObjectWithObjectStructure", $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } @@ -149,13 +149,13 @@ public function testAddingTypesMultipleTimesIsSavedOnlyOnce() $wsdl = $this->wsdl->toXML(); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure[]"') + substr_count($wsdl, 'wsdl:arrayType="tns:ComplexObjectWithObjectStructure[]"') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); } @@ -170,13 +170,13 @@ public function testAddingSingularThenArrayTypeIsRecognizedCorretly() $wsdl = $this->wsdl->toXML(); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure[]"') + substr_count($wsdl, 'wsdl:arrayType="tns:ComplexObjectWithObjectStructure[]"') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); $this->assertEquals(1, - substr_count($wsdl, '') + substr_count($wsdl, '') ); } @@ -199,15 +199,15 @@ public function testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllType $wsdl = $this->wsdl->toXml(); $this->assertEquals(1, - substr_count($wsdl, ''), + substr_count($wsdl, ''), 'No definition of complex type A found.' ); $this->assertEquals(1, - substr_count($wsdl, ''), + substr_count($wsdl, ''), 'No definition of complex type B array found.' ); $this->assertEquals(1, - substr_count($wsdl, 'wsdl:arrayType="tns:ZendTest.Soap.TestAsset.ComplexTypeB[]"'), + substr_count($wsdl, 'wsdl:arrayType="tns:ComplexTypeB[]"'), 'No usage of Complex Type B array found.' ); } diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php old mode 100644 new mode 100755 index ea76b1d7..58ec6054 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -117,12 +117,12 @@ public function testAddComplexTypeObject() { $return = $this->wsdl->addComplexType('\ZendTest\Soap\Wsdl\SequenceTest'); - $this->assertEquals('tns:ZendTest.Soap.Wsdl.SequenceTest', $return); + $this->assertEquals('tns:SequenceTest', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl ); } @@ -132,18 +132,18 @@ public function testAddComplexTypeArrayOfObject() $return = $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\ComplexTypeA[]'); - $this->assertEquals('tns:ArrayOfZendTest.Soap.TestAsset.ComplexTypeA', $return); + $this->assertEquals('tns:ArrayOfComplexTypeA', $return); $wsdl = $this->wsdl->toXML(); $this->assertContains( - '', + '', $wsdl, $wsdl ); $this->assertContains( - '', + '', $wsdl ); } diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php old mode 100644 new mode 100755 index e8500097..c3513f5b --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -77,7 +77,7 @@ public function testConstructorTypeMapSyntax() public function testCompositeThrowsExceptionOnInvalidType() { $strategy = new ComplexTypeStrategy\Composite(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid type given to Composite Type Map'); $strategy->connectTypeToStrategy(array(), 'strategy'); } @@ -90,7 +90,7 @@ public function testCompositeThrowsExceptionOnInvalidStrategy() $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Strategy for Complex Type \'Book\' is not a valid strategy'); $book = $strategy->getStrategyOfType('Book'); } - + public function testCompositeThrowsExceptionOnInvalidStrategyPart2() { $strategy = new ComplexTypeStrategy\Composite(array(), 'invalid'); @@ -99,8 +99,8 @@ public function testCompositeThrowsExceptionOnInvalidStrategyPart2() $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Default Strategy for Complex Types is not a valid strategy object'); $book = $strategy->getStrategyOfType('Anything'); } - - + + public function testCompositeDelegatesAddingComplexTypesToSubStrategies() { @@ -111,15 +111,15 @@ public function testCompositeDelegatesAddingComplexTypesToSubStrategies() $wsdl = new Wsdl('SomeService', 'http://example.com'); $strategy->setContext($wsdl); - $this->assertEquals('tns:ZendTest.Soap.Wsdl.Book', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Book')); - $this->assertEquals('tns:ZendTest.Soap.Wsdl.Cookie', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Cookie')); + $this->assertEquals('tns:Book', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Book')); + $this->assertEquals('tns:Cookie', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Cookie')); $this->assertEquals('xsd:anyType', $strategy->addComplexType('\ZendTest\Soap\Wsdl\Anything')); } public function testCompositeRequiresContextForAddingComplexTypesOtherwiseThrowsException() { $strategy = new ComplexTypeStrategy\Composite(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Cannot add complex type \'Test\''); $strategy->addComplexType('Test'); } diff --git a/test/WsdlTest.php b/test/WsdlTest.php old mode 100644 new mode 100755 index 6688e4c0..9bbcc622 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -535,7 +535,7 @@ function testGetType() function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() { $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); - $this->assertEquals('tns:ZendTest.Soap.TestAsset.WsdlTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); + $this->assertEquals('tns:WsdlTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof ComplexTypeStrategy\DefaultComplexType); // $wsdl2 = new Wsdl('MyService', 'http://localhost/MyService.php', false); @@ -546,7 +546,7 @@ function testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean() function testGetComplexTypeBasedOnStrategiesStringNames() { $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php', new \Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType); - $this->assertEquals('tns:ZendTest.Soap.TestAsset.WsdlTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); + $this->assertEquals('tns:WsdlTestClass', $wsdl->getType('\ZendTest\Soap\TestAsset\WsdlTestClass')); $this->assertTrue($wsdl->getComplexTypeStrategy() instanceof ComplexTypeStrategy\DefaultComplexType); $wsdl2 = new Wsdl('MyService', 'http://localhost/MyService.php', new \Zend\Soap\Wsdl\ComplexTypeStrategy\AnyType); @@ -570,12 +570,12 @@ function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); $this->assertEquals(array('\ZendTest\Soap\TestAsset\WsdlTestClass' => - 'tns:ZendTest.Soap.TestAsset.WsdlTestClass'), + 'tns:WsdlTestClass'), $wsdl->getTypes()); $wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); $this->assertEquals(array('\ZendTest\Soap\TestAsset\WsdlTestClass' => - 'tns:ZendTest.Soap.TestAsset.WsdlTestClass'), + 'tns:WsdlTestClass'), $wsdl->getTypes()); } @@ -596,7 +596,7 @@ function testAddComplexType() . 'name="MyService" targetNamespace="http://localhost/MyService.php">' . '' . '' - . '' + . '' . '' . '' . '' From 4d13468940068dddfddc048819a5b3aed1801f91 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 8 Dec 2011 10:30:16 +0100 Subject: [PATCH 077/123] [SOAP] Fix file rights again --- src/AutoDiscover.php | 0 src/Wsdl.php | 0 test/AutoDiscoverTest.php | 0 test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 0 test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 0 test/Wsdl/CompositeStrategyTest.php | 0 test/WsdlTest.php | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/AutoDiscover.php mode change 100755 => 100644 src/Wsdl.php mode change 100755 => 100644 test/AutoDiscoverTest.php mode change 100755 => 100644 test/Wsdl/ArrayOfTypeComplexStrategyTest.php mode change 100755 => 100644 test/Wsdl/ArrayOfTypeSequenceStrategyTest.php mode change 100755 => 100644 test/Wsdl/CompositeStrategyTest.php mode change 100755 => 100644 test/WsdlTest.php diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php old mode 100755 new mode 100644 diff --git a/src/Wsdl.php b/src/Wsdl.php old mode 100755 new mode 100644 diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php old mode 100755 new mode 100644 diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php old mode 100755 new mode 100644 diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php old mode 100755 new mode 100644 diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php old mode 100755 new mode 100644 diff --git a/test/WsdlTest.php b/test/WsdlTest.php old mode 100755 new mode 100644 From 9eb6d85201e40cb2e809f8227be520c6843a1172 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 8 Dec 2011 10:54:46 +0100 Subject: [PATCH 078/123] [SOAP] Extract Discovery code into its own interface and have a ReflectionDiscovery implementation --- src/AutoDiscover.php | 99 +++++++------------ src/AutoDiscover/DiscoveryStrategy.php | 83 ++++++++++++++++ .../DiscoveryStrategy/ReflectionDiscovery.php | 63 ++++++++++++ test/AutoDiscoverTest.php | 1 - 4 files changed, 184 insertions(+), 62 deletions(-) create mode 100644 src/AutoDiscover/DiscoveryStrategy.php create mode 100644 src/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index fa4999c1..a385f5aa 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -30,7 +30,8 @@ Zend\Server\Reflection\AbstractFunction, Zend\Server\Reflection, Zend\Server\Reflection\Prototype, - Zend\Server\Reflection\ReflectionParameter; + Zend\Server\Reflection\ReflectionParameter, + Zend\Soap\AutoDiscover\DiscoveryStrategy\ReflectionDiscovery; /** * \Zend\Soap\AutoDiscover @@ -105,6 +106,13 @@ class AutoDiscover */ protected $_classMap = array(); + /** + * Discovery strategy for types and other method details. + * + * @var Zend\Soap\AutoDiscover\DiscoveryStrategy + */ + protected $_discoveryStrategy; + /** * Constructor * @@ -115,6 +123,8 @@ class AutoDiscover public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=null, $wsdlClass=null, array $classMap = array()) { $this->_reflection = new Reflection(); + $this->_discoveryStrategy = new ReflectionDiscovery(); + if ($strategy !== null) { $this->setComplexTypeStrategy($strategy); } @@ -128,6 +138,26 @@ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=n } } + /** + * Set the discovery strategy for method type and other information. + * + * @param AutoDiscover\DiscoveryStrategy $discoveryStrategy + * @return Zend\Soap\AutoDiscover + */ + public function setDiscoveryStrategy(DiscoveryStrategy $discoveryStrategy) + { + $this->_discoveryStrategy = $discoveryStrategy; + return $this; + } + + /** + * @return AutoDiscover\DiscoveryStrategy + */ + public function getDiscoveryStrategy() + { + return $this->_discoveryStrategy; + } + /** * Get the class map of php to wsdl qname types. * @@ -144,6 +174,7 @@ public function getClassMap() public function setClassMap($classMap) { $this->_classMap = $classMap; + return $this; } /** @@ -373,60 +404,6 @@ protected function _generateWsdl(array $reflectionMethods) return $wsdl; } - /** - * Get the function parameters php type. - * - * Default implementation assumes the default param doc-block tag. - * - * @param ReflectionParameter $param - * @return string - */ - protected function _getFunctionParameterType(ReflectionParameter $param) - { - return $param->getType(); - } - - /** - * Get the functions return php type. - * - * Default implementation assumes the value of the return doc-block tag. - * - * @param AbstractFunction $function - * @param Prototype $prototype - * @return type - */ - protected function _getFunctionReturnType(AbstractFunction $function, Prototype $prototype) - { - return $prototype->getReturnType(); - } - - /** - * Detect if the function is a one-way or two-way operation. - * - * Default implementation assumes one-way, when return value is "void". - * - * @param AbstractFunction $function - * @param Prototype $prototype - * @return type - */ - protected function _isFunctionOneWay(AbstractFunction $function, Prototype $prototype) - { - return $prototype->getReturnType() == 'void'; - } - - /** - * Detect the functions documentation. - * - * Default implementation uses docblock description. - * - * @param AbstractFunction $function - * @return type - */ - protected function _getFunctionDocumentation(AbstractFunction $function) - { - return $function->getDescription(); - } - /** * Add a function to the WSDL document. * @@ -464,7 +441,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) foreach ($prototype->getParameters() as $param) { $sequenceElement = array( 'name' => $param->getName(), - 'type' => $wsdl->getType($this->_getFunctionParameterType($param)) + 'type' => $wsdl->getType($this->_discoveryStrategy->getFunctionParameterType($param)) ); if ($param->isOptional()) { $sequenceElement['nillable'] = 'true'; @@ -480,12 +457,12 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } else { // RPC style: add each parameter as a typed part foreach ($prototype->getParameters() as $param) { - $args[$param->getName()] = array('type' => $wsdl->getType($this->_getFunctionParameterType($param))); + $args[$param->getName()] = array('type' => $wsdl->getType($this->_discoveryStrategy->getFunctionParameterType($param))); } } $wsdl->addMessage($functionName . 'In', $args); - $isOneWayMessage = $this->_isFunctionOneWay($function, $prototype); + $isOneWayMessage = $this->_discoveryStrategy->isFunctionOneWay($function, $prototype); if($isOneWayMessage == false) { // Add the output message (return value) @@ -496,7 +473,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) if ($prototype->getReturnType() != "void") { $sequence[] = array( 'name' => $functionName . 'Result', - 'type' => $wsdl->getType($this->_getFunctionReturnType($function, $prototype)) + 'type' => $wsdl->getType($this->_discoveryStrategy->getFunctionReturnType($function, $prototype)) ); } $element = array( @@ -507,7 +484,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) $args['parameters'] = array('element' => $wsdl->addElement($element)); } else if ($prototype->getReturnType() != "void") { // RPC style: add the return value as a typed part - $args['return'] = array('type' => $wsdl->getType($this->_getFunctionReturnType($function, $prototype))); + $args['return'] = array('type' => $wsdl->getType($this->_discoveryStrategy->getFunctionReturnType($function, $prototype))); } $wsdl->addMessage($functionName . 'Out', $args); } @@ -518,7 +495,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } else { $portOperation = $wsdl->addPortOperation($port, $functionName, 'tns:' . $functionName . 'In', false); } - $desc = $this->_getFunctionDocumentation($function); + $desc = $this->_discoveryStrategy->getFunctionDocumentation($function); if (strlen($desc) > 0) { $wsdl->addDocumentation($portOperation, $desc); } diff --git a/src/AutoDiscover/DiscoveryStrategy.php b/src/AutoDiscover/DiscoveryStrategy.php new file mode 100644 index 00000000..4f00cb0d --- /dev/null +++ b/src/AutoDiscover/DiscoveryStrategy.php @@ -0,0 +1,83 @@ +getDescription(); + } + + public function getFunctionParameterType(ReflectionParameter $param) + { + return $param->getType(); + } + + public function getFunctionReturnType(AbstractFunction $function, Prototype $prototype) + { + return $prototype->getReturnType(); + } + + public function isFunctionOneWay(AbstractFunction $function, Prototype $prototype) + { + return $prototype->getReturnType() == 'void'; + } +} diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 5ab1c7d0..f3490fa5 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -334,7 +334,6 @@ function testSetClassWithResponseReturnPartCompabilityMode() unlink(__DIR__.'/TestAsset/setclass.wsdl'); } - function testAddFunctionSimple() { $scriptUri = 'http://localhost/my_script.php'; From 855e9a0dd66b92105cf73f1c2ad3309d40c1edd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wrzeszcz?= Date: Fri, 6 Jan 2012 20:42:40 +0100 Subject: [PATCH 079/123] Test case for pull request zendframework/zf2#706. --- test/ServerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/ServerTest.php b/test/ServerTest.php index c253b215..36fd1199 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -324,6 +324,17 @@ public function testSetClass() $this->assertSame($server, $r); } + // GitHub PR #706 + public function testSetClassWithObject() + { + $server = new Server(); + + // Correct class name should pass + $object = new \ZendTest\Soap\TestAsset\ServerTestClass(); + $r = $server->setClass($object); + $this->assertSame($server, $r); + } + public function testSetClassTwiceThrowsException() { $server = new Server(); From ad50dbb0fe0785aa18e5b15790b2eba24eb59275 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 9 Jan 2012 11:23:00 -0600 Subject: [PATCH 080/123] Added @group annotation for new test --- test/ServerTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ServerTest.php b/test/ServerTest.php index 01ff2865..c6aba20d 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -324,7 +324,9 @@ public function testSetClass() $this->assertSame($server, $r); } - // GitHub PR #706 + /** + * @group PR-706 + */ public function testSetClassWithObject() { $server = new Server(); From 22d3660445cd113ec125b374ceb76b64d47215e9 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 11 Jan 2012 22:26:28 +0100 Subject: [PATCH 081/123] [SOAP] Added DocumentLiteralWrapper for bindingstyle document, encoding literal style SOAP servers (such as .NET works) as an equiavlent to the already existing DotNet local client. --- src/Exception/BadMethodCallException.php | 9 + src/Server/DocumentLiteralWrapper.php | 184 +++++++++++++++++++++ test/Server/DocumentLiteralWrapperTest.php | 68 ++++++++ test/Server/_files/calculator.wsdl | 52 ++++++ 4 files changed, 313 insertions(+) create mode 100644 src/Exception/BadMethodCallException.php create mode 100644 src/Server/DocumentLiteralWrapper.php create mode 100644 test/Server/DocumentLiteralWrapperTest.php create mode 100644 test/Server/_files/calculator.wsdl diff --git a/src/Exception/BadMethodCallException.php b/src/Exception/BadMethodCallException.php new file mode 100644 index 00000000..8349bd90 --- /dev/null +++ b/src/Exception/BadMethodCallException.php @@ -0,0 +1,9 @@ +x = 10; + * $addRequest->y = 20; + * + * This object does not match the signature of the server-side + * MyCalculatorService and lead to failure. + * + * Also the response object in this case is supposed to be an array + * or object with a property "addResult": + * + * $addResponse = new \stdClass; + * $addResponse->addResult = 30; + * + * To keep your service object code free from this implementation detail + * of SOAP this wrapper service handles the parsing between the formats. + * + * @example + * + * $service = new MyCalculatorService(); + * $soap = new \Zend\Soap\Server($wsdlFile); + * $soap->setObject(new \Zend\Soap\Server\DocumentLiteralWrapper($service)); + * $soap->handle(); + * + * @uses ReflectionClass + * @category Zend + * @package Zend_Soap + * @subpackage Server + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class DocumentLiteralWrapper +{ + /** + * @var object + */ + protected $_object; + + /** + * @var ReflectionObject + */ + protected $_reflection; + + /** + * Pass Service object to the constructor + * + * @param object $object + */ + public function __construct($object) + { + $this->_object = $object; + $this->_reflection = new \ReflectionObject($this->_object); + } + + /** + * Proxy method that does the heavy document/literal decomposing. + * + * @param string $method + * @param array $args + * @return mixed + */ + public function __call($method, $args) + { + $this->_assertOnlyOneArgument($args); + $this->_assertServiceDelegateHasMethod($method); + + $delegateArgs = $this->_parseArguments($method, $args[0]); + $ret = call_user_func_array(array($this->_object, $method), $delegateArgs); + return $this->_getResultMessage($method, $ret); + } + + /** + * Parse the document/literal wrapper into arguments to call the real + * service. + * + * @param string $method + * @param object $document + * @return array + */ + protected function _parseArguments($method, $document) + { + $reflMethod = $this->_reflection->getMethod($method); + $params = array(); + foreach ($reflMethod->getParameters() as $param) { + $params[$param->getName()] = $param; + } + + $delegateArgs = array(); + foreach (get_object_vars($document) as $argName => $argValue) { + if (!isset($params[$argName])) { + throw new UnexpectedValueException(sprintf( + "Recieved unknown argument %s which is not an argument to %s::%s", + get_class($this->_object), $method + )); + } + $delegateArgs[$params[$argName]->getPosition()] = $argValue; + } + return $delegateArgs; + } + + protected function _getResultMessage($method, $ret) + { + return array($method.'Result' => $ret); + } + + protected function _assertServiceDelegateHasMethod($method) + { + if ( !$this->_reflection->hasMethod($method) ) { + throw new BadMethodCallException(sprintf( + "Method %s does not exist on delegate object %s", + $method, get_class($this->_object) + )); + } + } + + protected function _assertOnlyOneArgument($args) + { + if (count($args) != 1) { + throw new UnexpectedValueException(sprintf( + "Expecting exactly one argument that is the document/literal wrapper, got %d", + count($args))); + } + } +} + diff --git a/test/Server/DocumentLiteralWrapperTest.php b/test/Server/DocumentLiteralWrapperTest.php new file mode 100644 index 00000000..a0137689 --- /dev/null +++ b/test/Server/DocumentLiteralWrapperTest.php @@ -0,0 +1,68 @@ +setObject(new DocumentLiteralWrapper(new MyCalculatorService)); + + // The local client needs an abstraction for this pattern aswell, + // this is just a test so we use the messy way. + $client = new \Zend\Soap\Client\Local($server, __DIR__ . self::WSDL); + $ret = $client->add(array('x' => 10, 'y' => 20)); + + $this->assertInstanceOf('stdClass', $ret); + $this->assertEquals(30, $ret->addResult); + } +} + +class MyCalculatorService +{ + /** + * @param int $x + * @param int $y + * @return int + */ + public function add($x, $y) + { + return $x+$y; + } +} diff --git a/test/Server/_files/calculator.wsdl b/test/Server/_files/calculator.wsdl new file mode 100644 index 00000000..4d170db4 --- /dev/null +++ b/test/Server/_files/calculator.wsdl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + @param int $x + + + + + + + + + + + + + + + + + + + + + + + + + + + + From fcc59de74bf10fed271d05681cc7add864a73beb Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 12 Jan 2012 14:20:11 -0600 Subject: [PATCH 082/123] Fixed test reporting issue with DocumentLiteral test - Test needed to run in a separate process... - which exposed issues with TestConfiguration, requiring that we test if a constant is defined prior to defining it. - Also, moved "MyCalculatorService", consumed by DocumentLiteralWrapperTest, to a separate TestAsset file --- test/Server/DocumentLiteralWrapperTest.php | 31 ++++++---------- test/TestAsset/MyCalculatorService.php | 41 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 test/TestAsset/MyCalculatorService.php diff --git a/test/Server/DocumentLiteralWrapperTest.php b/test/Server/DocumentLiteralWrapperTest.php index a0137689..23a5f6f8 100644 --- a/test/Server/DocumentLiteralWrapperTest.php +++ b/test/Server/DocumentLiteralWrapperTest.php @@ -19,14 +19,13 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @namespace - */ namespace ZendTest\Soap\Server; -use Zend\Soap\Server, +use Zend\Soap\Client\Local as SoapClient, + Zend\Soap\Server, Zend\Soap\ServerException, - Zend\Soap\Server\DocumentLiteralWrapper; + Zend\Soap\Server\DocumentLiteralWrapper, + ZendTest\Soap\TestAsset\MyCalculatorService; class DocumentLiteralWrapperTest extends \PHPUnit_Framework_TestCase { @@ -39,30 +38,20 @@ public function setUp() ini_set("soap.wsdl_cache_enabled", 0); } + /** + * @runInSeparateProcess + */ public function testDelegate() { $server = new Server(__DIR__ . self::WSDL); $server->setObject(new DocumentLiteralWrapper(new MyCalculatorService)); - // The local client needs an abstraction for this pattern aswell, - // this is just a test so we use the messy way. - $client = new \Zend\Soap\Client\Local($server, __DIR__ . self::WSDL); + // The local client needs an abstraction for this pattern as well. + // This is just a test so we use the messy way. + $client = new SoapClient($server, __DIR__ . self::WSDL); $ret = $client->add(array('x' => 10, 'y' => 20)); $this->assertInstanceOf('stdClass', $ret); $this->assertEquals(30, $ret->addResult); } } - -class MyCalculatorService -{ - /** - * @param int $x - * @param int $y - * @return int - */ - public function add($x, $y) - { - return $x+$y; - } -} diff --git a/test/TestAsset/MyCalculatorService.php b/test/TestAsset/MyCalculatorService.php new file mode 100644 index 00000000..853b0109 --- /dev/null +++ b/test/TestAsset/MyCalculatorService.php @@ -0,0 +1,41 @@ + Date: Fri, 13 Jan 2012 10:46:44 +0100 Subject: [PATCH 083/123] Basic JSON client. --- src/Server.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Server.php b/src/Server.php index bce93267..5cc26839 100644 --- a/src/Server.php +++ b/src/Server.php @@ -810,7 +810,7 @@ public function handle($request = null) ob_start(); if($setRequestException instanceof \Exception) { // Send SOAP fault message if we've catched exception - $soap->fault("Sender", $setRequestException->getMessage()); + $soap->fault('Sender', $setRequestException->getMessage()); } else { try { $soap->handle($this->_request); @@ -940,6 +940,6 @@ public function fault($fault = null, $code = "Receiver") */ public function handlePhpErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null) { - throw $this->fault($errstr, "Receiver"); + throw $this->fault($errstr, 'Receiver'); } } From 3861ce8f35cc8b360467860be1ac4d274a585085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wrzeszcz?= Date: Fri, 13 Jan 2012 11:02:12 +0100 Subject: [PATCH 084/123] Unified servers behavior in handling response output. --- src/Server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server.php b/src/Server.php index 5cc26839..824ea170 100644 --- a/src/Server.php +++ b/src/Server.php @@ -709,7 +709,7 @@ public function getLastRequest() * @param boolean $flag * @return \Zend\Soap\Server */ - public function setReturnResponse($flag) + public function setReturnResponse($flag = true) { $this->_returnResponse = ($flag) ? true : false; return $this; From 7386efdfd55fcd2b7cd280ece35ce6b1fa140667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wrzeszcz?= Date: Fri, 13 Jan 2012 13:04:26 +0100 Subject: [PATCH 085/123] Unified $argv argument handling in RPC servers setClass() method. --- src/Server.php | 5 ++--- test/ServerTest.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Server.php b/src/Server.php index 824ea170..545bfe59 100644 --- a/src/Server.php +++ b/src/Server.php @@ -559,10 +559,9 @@ public function setClass($class, $namespace = '', $argv = null) } $this->_class = $class; - if (1 < func_num_args()) { + if (2 < func_num_args()) { $argv = func_get_args(); - array_shift($argv); - $this->_classArgs = $argv; + $this->_classArgs = array_slice($argv, 2); } return $this; diff --git a/test/ServerTest.php b/test/ServerTest.php index c6aba20d..e35a1f2e 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -354,7 +354,7 @@ public function testSetClassWithArguments() $server = new Server(); // Correct class name should pass - $r = $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass', 1, 2, 3, 4); + $r = $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass', null, 1, 2, 3, 4); $this->assertSame($server, $r); } From 5b62f9d7d9c7ad215191fbda36ae4f7880dfe07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Wrzeszcz?= Date: Fri, 13 Jan 2012 14:02:15 +0100 Subject: [PATCH 086/123] Unified method name for returning last produced response. --- src/Server.php | 2 +- test/ServerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Server.php b/src/Server.php index 545bfe59..793015c7 100644 --- a/src/Server.php +++ b/src/Server.php @@ -729,7 +729,7 @@ public function getReturnResponse() * * @return string */ - public function getLastResponse() + public function getResponse() { return $this->_response; } diff --git a/test/ServerTest.php b/test/ServerTest.php index e35a1f2e..249bdc51 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -599,7 +599,7 @@ public function testGetLastResponse() $server->handle($request); - $this->assertEquals($expectedResponse, $server->getLastResponse()); + $this->assertEquals($expectedResponse, $server->getResponse()); } public function testHandle() From 2989a80d11c9234203e26ff1fb8b360878505d20 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 16 Jan 2012 11:22:40 -0600 Subject: [PATCH 087/123] CS cleanup of JSON-compliant support - CS cleanup -- imports, docblocks, etc. - Ensured that AMF server also supports new Server interface features --- src/Client.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Client.php b/src/Client.php index 2e1a732c..b0de2cd2 100644 --- a/src/Client.php +++ b/src/Client.php @@ -19,26 +19,20 @@ * @license http://framework.zend.com/license/new-bsd New BSD License */ -/** - * @namespace - */ namespace Zend\Soap; -use Zend\Server\Client as ClientInterface; + +use Zend\Server\Client as ServerClient; /** * \Zend\Soap\Client\Client * - * @uses \Zend\Soap\Client\Common - * @uses \Zend\Soap\Client\Exception - * @uses \Zend\Soap\Client\Local - * @uses \Zend\Soap\Server * @category Zend * @package Zend_Soap * @subpackage Client * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Client implements ClientInterface +class Client implements ServerClient { /** * Encoding @@ -1105,8 +1099,8 @@ public function __call($name, $arguments) /** * Send an RPC request to the service for a specific method. * - * @param string $method Name of the method we want to call. - * @param array $params List of parameters for the method. + * @param string $method Name of the method we want to call. + * @param array $params List of parameters for the method. * @return mixed Returned results. */ public function call($method, $params = array()) From 10dd34ed2464ba2bba3f64b4e6c1605ffd8639b6 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 4 Apr 2012 00:27:17 +0200 Subject: [PATCH 088/123] Adding shell script to run tests It iterates over tested components and runs phpunit for each of them --- .travis/run-tests.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .travis/run-tests.sh diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh new file mode 100644 index 00000000..47d0c4a0 --- /dev/null +++ b/.travis/run-tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash +travisdir=$(dirname $(readlink /proc/$$/fd/255)) +testdir="$travisdir/../tests" +testedcomponents=(`cat "$travisdir/tested-components"`) + +for tested in "${testedcomponents[@]}" + do phpunit -c $testdir/phpunit.xml $testdir/$tested +done From cca7050079d8955b7648229357bd2d58a42a870f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 4 Apr 2012 00:29:10 +0200 Subject: [PATCH 089/123] Adding script used to configure the test suite --- .travis/TestConfiguration.php | 825 ++++++++++++++++++++++++++++++++++ 1 file changed, 825 insertions(+) create mode 100644 .travis/TestConfiguration.php diff --git a/.travis/TestConfiguration.php b/.travis/TestConfiguration.php new file mode 100644 index 00000000..fd894704 --- /dev/null +++ b/.travis/TestConfiguration.php @@ -0,0 +1,825 @@ + test disabling output buffering in + * dispatcher + */ +defined('TESTS_ZEND_CONTROLLER_DISPATCHER_OB') || define('TESTS_ZEND_CONTROLLER_DISPATCHER_OB', false); + +/** + * Zend_Crypt related constantes + * + * TESTS_ZEND_CRYPT_OPENSSL_CONF => location of an openssl.cnf file for use + * with RSA encryption + */ +defined('TESTS_ZEND_CRYPT_OPENSSL_CONF') || define('TESTS_ZEND_CRYPT_OPENSSL_CONF', false); + +/** + * Zend_Db_Adapter_Pdo_Mysql and Zend_Db_Adapter_Mysqli + * + * There are separate properties to enable tests for the PDO_MYSQL adapter and + * the native Mysqli adapters, but the other properties are shared between the + * two MySQL-related Zend_Db adapters. + */ +defined('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME', '127.0.0.1'); +defined('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME', null); +defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD', null); +defined('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE', 'test'); +defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT', 3306); + +/** + * Zend_Db_Adapter_Pdo_Sqlite + * + * Username and password are irrelevant for SQLite. + */ +defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE', ':memory:'); + +/** + * Zend_Db_Adapter_Pdo_Mssql + * + * Note that you need to patch your ntwdblib.dll, the one that + * comes with PHP does not work. See user comments at + * http://us2.php.net/manual/en/ref.mssql.php + */ +defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME', '127.0.0.1'); +defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME', null); +defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD', null); +defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE', 'test'); + +/** + * Zend_Db_Adapter_Pdo_Pgsql + */ +defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME', '127.0.0.1'); +defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME', null); +defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD', null); +defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE', 'postgres'); + +/** + * Zend_Db_Adapter_Oracle and Zend_Db_Adapter_Pdo_Oci + * + * There are separate properties to enable tests for the PDO_OCI adapter and + * the native Oracle adapter, but the other properties are shared between the + * two Oracle-related Zend_Db adapters. + */ +defined('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME', '127.0.0.1'); +defined('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME', null); +defined('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD', null); +defined('TESTS_ZEND_DB_ADAPTER_ORACLE_SID') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_SID', 'xe'); + +/** + * Zend_Db_Adapter_Db2 and Zend_Db_Adapter_Pdo_Ibm + * There are separate properties to enable tests for the PDO_IBM adapter and + * the native DB2 adapter, but the other properties are shared between the + * two related Zend_Db adapters. + */ +defined('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME', '127.0.0.1'); +defined('TESTS_ZEND_DB_ADAPTER_DB2_PORT') || define('TESTS_ZEND_DB_ADAPTER_DB2_PORT', 50000); +defined('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME', null); +defined('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD', null); +defined('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE', 'sample'); + +/** + * Zend_Db_Adapter_Sqlsrv + * Note: Make sure that you create the "test" database and set a + * username and password + * + */ +defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED', false); +defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME', 'localhost\SQLEXPRESS'); +defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME', null); +defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD', null); +defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE', 'test'); + +/** + * Zend_Feed_Reader tests + * + * If the ONLINE_ENABLED property is false, only tests that can be executed + * without network connectivity are run; when enabled, all tests will run. + */ +defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED') || define('TESTS_ZEND_FEED_READER_ONLINE_ENABLED', false); + +/** + * Zend_Gdata tests + * + * If the ONLINE_ENABLED property is false, only tests that can be executed with + * a mock HTTP client are run. No request is sent to the Google Gdata servers. + * If ONLINE_ENABLED is true, some tests may make requests to the remote + * servers. This does not work if you are running tests on a disconnected + * client host. Also, the tests may show as failures if the Google servers + * cannot be reached or if they do not respond for another reason. + * + * If the CLIENTLOGIN_ENABLED property below is false, the authenticated + * tests are reported Skipped in the test run. Set this property to true + * to enable tests that require ClientLogin authentication. Enter your + * Google login credentials in the EMAIL and PASSWORD properties below. + * + * Edit TestConfiguration.php, not TestConfiguration.php.dist. + * Never commit plaintext passwords to the source code repository. + * + * Note: the GData tests currently require that the TZID env variable + * be set or the timezone otherwise configured. You'll see errors from the + * tests if this is not the case. + */ +defined('TESTS_ZEND_GDATA_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_ONLINE_ENABLED', false); +defined('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED') || define('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED', false); + +/* + * The credentials provided here should be only for a TEST account. + * Data for various services in this account may be added to, updated, + * or deleted based upon the actions of these test accounts. + */ +defined('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL') || define('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL', 'example@example.com'); +defined('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD') || define('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD', 'password'); + +/* + * This is the ID of a blank blog. There is no need to have + * any content in this blog. Also, blogs can only be used + * several times for the purpose of these test cases before + * they must be deleted and recreated. Otherwise, the tests + * will start failing, as posts to Blogger will return a 201 Created + * response even though the entry was not posted to the blog. + * This problem is being investigated. + */ +defined('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED', false); +defined('TESTS_ZEND_GDATA_BLOG_ID') || define('TESTS_ZEND_GDATA_BLOG_ID', '1111111111111111111'); + +/* + * This is the key for a spreadsheet with data only in the first row of + * the spreadsheet. The strings 'a1', 'b1', 'c1', 'd1' should be in the + * corresponding cell locations. + */ +defined('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED', false); +defined('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY') || define('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY', 'o01111111111111111111.1111111111111111111'); +defined('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID') || define('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID', 'default'); + +/* + * This indicates that online tests for the Google Calendar API should + * be performed. The default calendar will be used. + */ +defined('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED', false); + +/* + * This is the fully-qualified domain name for a domiain hosted using + * Google Apps. This domain must be registered with Google Apps and + * have API access enabled. This should be a TEST domain only. + */ +defined('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED', false); +defined('TESTS_ZEND_GDATA_GAPPS_DOMAIN') || define('TESTS_ZEND_GDATA_GAPPS_DOMAIN', 'example.com.invalid'); +defined('TESTS_ZEND_GDATA_GAPPS_EMAIL') || define('TESTS_ZEND_GDATA_GAPPS_EMAIL', 'example@example.com'); +defined('TESTS_ZEND_GDATA_GAPPS_PASSWORD') || define('TESTS_ZEND_GDATA_GAPPS_PASSWORD', 'password'); + +/* + * This is the ONLINE_ENABLED property for Google Base. + */ +defined('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED', false); + +/* + * This indicates that online tests for the Books Search data API + * should be performed. + */ +defined('TESTS_ZEND_GDATA_BOOKS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_BOOKS_ONLINE_ENABLED', false); + +/* + * This indicates that online tests for the YouTube data API should + * be performed. + */ +defined('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED', false); + +/* + * This is the username to use for retrieving subscriptions, etc + */ +defined('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT') || define('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT', 'zfgdata'); + +/* + * This is the developer key to access the YouTube API + */ +defined('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY') || define('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY', 'your_developer_key_here'); + +/* + * This is the client ID to access the YouTube API + */ +defined('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID') || define('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID', 'ZF_UnitTests_unknown'); + +/* + * This indicates that online tests for the Google Documents API should + * be performed. + */ +defined('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED', false); + +/* + * This indicates that online tests for the GData Photos API should + * be performed. + */ +defined('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED', false); + +/* + * This indicates that online tests for the Google Health API should + * be performed. + */ +defined('TESTS_ZEND_GDATA_HEALTH_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_HEALTH_ONLINE_ENABLED', false); + +/** + * Zend_Http_Client tests + * + * To enable the dynamic Zend_Http_Client tests, you will need to symbolically + * link or copy the files in tests/Zend/Http/Client/_files to a directory + * under your web server(s) document root and set this constant to point to the + * URL of this directory. + */ +defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') || define('TESTS_ZEND_HTTP_CLIENT_BASEURI', false); + +/** + * Zend_Http_Client_Proxy tests + * + * HTTP proxy to be used for testing the Proxy adapter. Set to a string of + * the form 'host:port'. Set to null to skip HTTP proxy tests. + */ +defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY', false); +defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER', ''); +defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS', ''); + +/** + * Zend_Loader_Autoloader multi-version support tests + * + * ENABLED: whether or not to run the multi-version tests + * PATH: path to a directory containing multiple ZF version installs + * LATEST: most recent ZF version in the PATH + * e.g., "1.9.2" + * LATEST_MAJOR: most recent ZF major version in the PATH to test against + * e.g., "1.9.2" + * LATEST_MINOR: most recent ZF minor version in the PATH to test against + * e.g., "1.8.4PL1" + * SPECIFIC: specific ZF version in the PATH to test against + * e.g., "1.7.6" + * As an example, consider the following tree: + * ZendFramework/ + * |-- 1.9.2 + * |-- ZendFramework-1.9.1-minimal + * |-- 1.8.4PL1 + * |-- 1.8.4 + * |-- ZendFramework-1.8.3 + * |-- 1.7.8 + * |-- 1.7.7 + * |-- 1.7.6 + * You would then set the value of "LATEST" and "LATEST_MAJOR" to "1.9.2", and + * could choose between "1.9.2", "1.8.4PL1", and "1.7.8" for "LATEST_MINOR", + * and any version number for "SPECIFIC". "PATH" would point to the parent + * "ZendFramework" directory. + */ +defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_ENABLED') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_ENABLED', false); +defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_PATH') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_PATH', false); +defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST', false); +defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MAJOR') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MAJOR', false); +defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MINOR') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MINOR', false); +defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_SPECIFIC') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_SPECIFIC', false); + +/** + * Zend_Ldap online tests + */ +defined('TESTS_ZEND_LDAP_ONLINE_ENABLED') || define('TESTS_ZEND_LDAP_ONLINE_ENABLED', false); + +/* These largely map to the options described in the Zend_Ldap and + * Zend_Auth_Adapter_Ldap documentation. + * + * Example Configuration for Active Directory: + * HOST: dc1.w.net + * USE_START_TLS: true + * USE_SSL: false + * USERNAME: CN=User 1,CN=Users,DC=w,DC=net + * PRINCIPAL_NAME: user1@w.net + * LDAP_PASSWORD: pass1 + * BASE_DN: CN=Users,DC=w,DC=net + * DOMAIN_NAME: w.net + * ACCOUNT_DOMAIN_NAME_SHORT: W + * ALT_USERNAME: user2 + * ALT_DN: CN=User 2,CN=Users,DC=w,DC=net + * ALT_PASSWORD: pass2 + * + * Example Configuration for OpenLDAP + * HOST: s0.foo.net + * USERNAME: CN=user1,DC=foo,DC=net + * PRINCIPAL_NAME: user1@foo.net + * LDAP_PASSWORD: pass1 + * BIND_REQUIRES_DN: true + * BASE_DN: OU=Sales,DC=w,DC=net + * DOMAIN_NAME: foo.net + * ACCOUNT_DOMAIN_NAME_SHORT: FOO + * ALT_USERNAME: abaker + * ALT_DN: CN=Alice Baker,OU=Sales,DC=foo,DC=net + * ALT_PASSWORD: apass + */ +defined('TESTS_ZEND_LDAP_HOST') || define('TESTS_ZEND_LDAP_HOST', 'localhost'); +//defined('TESTS_ZEND_LDAP_PORT') || define('TESTS_ZEND_LDAP_PORT', 389); +defined('TESTS_ZEND_LDAP_USE_START_TLS') || define('TESTS_ZEND_LDAP_USE_START_TLS', true); +//defined('TESTS_ZEND_LDAP_USE_SSL') || define('TESTS_ZEND_LDAP_USE_SSL', false); +defined('TESTS_ZEND_LDAP_USERNAME') || define('TESTS_ZEND_LDAP_USERNAME', 'CN=someUser,DC=example,DC=com'); +defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', 'someUser@example.com'); +defined('TESTS_ZEND_LDAP_PASSWORD') || define('TESTS_ZEND_LDAP_PASSWORD', null); +defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') || define('TESTS_ZEND_LDAP_BIND_REQUIRES_DN', true); +defined('TESTS_ZEND_LDAP_BASE_DN') || define('TESTS_ZEND_LDAP_BASE_DN', 'OU=Sales,DC=example,DC=com'); +//defined('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') || define('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT', '(&(objectClass=posixAccount)(uid=%s))'); +defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME', 'example.com'); +defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT', 'EXAMPLE'); +defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', 'anotherUser'); +defined('TESTS_ZEND_LDAP_ALT_DN') || define('TESTS_ZEND_LDAP_ALT_DN', 'CN=Another User,OU=Sales,DC=example,DC=com'); +defined('TESTS_ZEND_LDAP_ALT_PASSWORD') || define('TESTS_ZEND_LDAP_ALT_PASSWORD', null); // Used in Zend_Auth_Adapter_Ldap tests +//(defined('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE') || define('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE', 'OU=Test,OU=Sales,DC=example,DC=com'); + +/** + * Zend_Locale tests + * + * If the TESTS_ZEND_LOCALE_FORMAT_SETLOCALE property below is a valid, + * locally recognized locale (try "locale -a"), then all tests in + * tests/Zend/Locale/ test suites will execute *after* + * setlocale(LC_ALL, TESTS_ZEND_LOCALE_FORMAT_SETLOCALE); + * Primarily, this switches certain PHP functions to emit "localized" output, + * including the built-in "to string" for integer and float conversions. + * Thus, a locale of 'fr_FR' yields number-to-string conversions in a + * localized form with the decimal place separator chosen via: + * setlocale(LC_ALL, 'fr_FR@euro'); + */ +//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr'); +//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr_FR@euro'); +defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE') || define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', false); + +/** + * Zend_Date tests + * + * If the BCMATH_ENABLED property below is false, all arithmetic + * operations will use ordinary PHP math operators and functions. + * Otherwise, the bcmath functions will be used for unlimited precision. + * + * If the EXTENDED_COVERAGE property below is false, most of the I18N + * unit tests will not be computed... this speeds tests up to 80 minutes + * when doing reports. * + * Edit TestConfiguration.php, not TestConfiguration.php.dist. + */ +defined('TESTS_ZEND_LOCALE_BCMATH_ENABLED') || define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', true); +defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || define('TESTS_ZEND_I18N_EXTENDED_COVERAGE', true); + +/** + * Zend_Mail_Storage tests + * + * TESTS_ZEND_MAIL_SERVER_TESTDIR and TESTS_ZEND_MAIL_SERVER_FORMAT are used for POP3 and IMAP tests. + * TESTS_ZEND_MAIL_SERVER_FORMAT is the format your test mail server uses: 'mbox' or 'maildir'. The mail + * storage for the user specified in your POP3 or IMAP tests should be TESTS_ZEND_MAIL_SERVER_TESTDIR. Be + * careful: it's cleared before copying the files. If you want to copy the files manually set the dir + * to null (or anything == null). + * + * TESTS_ZEND_MAIL_TEMPDIR is used for testing write operations in local storages. If not set (== null) + * tempnam() is used. + */ +defined('TESTS_ZEND_MAIL_SERVER_TESTDIR') || define('TESTS_ZEND_MAIL_SERVER_TESTDIR', null); +defined('TESTS_ZEND_MAIL_SERVER_FORMAT') || define('TESTS_ZEND_MAIL_SERVER_FORMAT', 'mbox'); +defined('TESTS_ZEND_MAIL_TEMPDIR') || define('TESTS_ZEND_MAIL_TEMPDIR', null); + +/** + * Zend_Mail_Storage_Pop3 / Zend_Mail_Transport_Pop3 + * + * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail + * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR + */ +defined('TESTS_ZEND_MAIL_POP3_ENABLED') || define('TESTS_ZEND_MAIL_POP3_ENABLED', false); +defined('TESTS_ZEND_MAIL_POP3_HOST') || define('TESTS_ZEND_MAIL_POP3_HOST', 'localhost'); +defined('TESTS_ZEND_MAIL_POP3_USER') || define('TESTS_ZEND_MAIL_POP3_USER', 'test'); +defined('TESTS_ZEND_MAIL_POP3_PASSWORD') || define('TESTS_ZEND_MAIL_POP3_PASSWORD', ''); +// test SSL connections if enabled in your test server +defined('TESTS_ZEND_MAIL_POP3_SSL') || define('TESTS_ZEND_MAIL_POP3_SSL', true); +defined('TESTS_ZEND_MAIL_POP3_TLS') || define('TESTS_ZEND_MAIL_POP3_TLS', true); +// WRONG_PORT should be an existing server port, +// INVALID_PORT should be a non existing (each on defined host) +defined('TESTS_ZEND_MAIL_POP3_WRONG_PORT') || define('TESTS_ZEND_MAIL_POP3_WRONG_PORT', 80); +defined('TESTS_ZEND_MAIL_POP3_INVALID_PORT') || define('TESTS_ZEND_MAIL_POP3_INVALID_PORT', 3141); + +/** + * Zend_Mail_Storage_Imap / Zend_Mail_Transport_Imap + * + * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail + * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR + */ +defined('TESTS_ZEND_MAIL_IMAP_ENABLED') || define('TESTS_ZEND_MAIL_IMAP_ENABLED', false); +defined('TESTS_ZEND_MAIL_IMAP_HOST') || define('TESTS_ZEND_MAIL_IMAP_HOST', 'localhost'); +defined('TESTS_ZEND_MAIL_IMAP_USER') || define('TESTS_ZEND_MAIL_IMAP_USER', 'test'); +defined('TESTS_ZEND_MAIL_IMAP_PASSWORD') || define('TESTS_ZEND_MAIL_IMAP_PASSWORD', ''); +// test SSL connections if enabled in your test server +defined('TESTS_ZEND_MAIL_IMAP_SSL') || define('TESTS_ZEND_MAIL_IMAP_SSL', true); +defined('TESTS_ZEND_MAIL_IMAP_TLS') || define('TESTS_ZEND_MAIL_IMAP_TLS', true); +// WRONG_PORT should be an existing server port, +// INVALID_PORT should be a non-existing (each on defined host) +defined('TESTS_ZEND_MAIL_IMAP_WRONG_PORT') || define('TESTS_ZEND_MAIL_IMAP_WRONG_PORT', 80); +defined('TESTS_ZEND_MAIL_IMAP_INVALID_PORT') || define('TESTS_ZEND_MAIL_IMAP_INVALID_PORT', 3141); + + +/** + * Zend_Mail_Storage_Maildir test + * + * Before enabling this test you have to unpack messages.tar in + * Zend/Mail/_files/test.maildir/cur/ and remove the tar for this test to work. + * That's because the messages files have a colon in the filename and that's a + * forbidden character on Windows. + */ +defined('TESTS_ZEND_MAIL_MAILDIR_ENABLED') || define('TESTS_ZEND_MAIL_MAILDIR_ENABLED', false); + +/** + * Zend_Mail_Transport_Smtp + * + * @todo TO be implemented + */ +defined('TESTS_ZEND_MAIL_SMTP_ENABLED') || define('TESTS_ZEND_MAIL_SMTP_ENABLED', false); +defined('TESTS_ZEND_MAIL_SMTP_HOST') || define('TESTS_ZEND_MAIL_SMTP_HOST', 'localhost'); +defined('TESTS_ZEND_MAIL_SMTP_PORT') || define('TESTS_ZEND_MAIL_SMTP_PORT', 25); +defined('TESTS_ZEND_MAIL_SMTP_USER') || define('TESTS_ZEND_MAIL_SMTP_USER', 'testuser'); +defined('TESTS_ZEND_MAIL_SMTP_PASSWORD') || define('TESTS_ZEND_MAIL_SMTP_PASSWORD', 'testpassword'); +defined('TESTS_ZEND_MAIL_SMTP_AUTH') || define('TESTS_ZEND_MAIL_SMTP_AUTH', false); +// AUTH can be set to false or a string of AUTH method (e.g. LOGIN, PLAIN, CRAMMD5 or DIGESTMD5) + +/** + * Zend_Queue Test Configuration constants + * + * The Zend_Queue_Adapter_Db constant should be a JSON-encoded string + * representing a configuration object for Zend_Db::factory(). For example: + * { + * type: "pdo_mysql", + * host: "127.0.0.1", + * port: 3306, + * username: "queue", + * password: "queue", + * dbname: "queue" + * } + * + * The PlatformJobQueue adapter expects two parameters, the host and password. + * The HOST string should include both the host and port (typically 10003): + * 127.0.0.1:10003 + * When running tests against PlatformJobQueue, it's best to do so where + * Platform is installed on localhost and has maximum workers set to 20 + * (default is 5); do so with this zend.ini setting: + * zend_jq.max_num_of_request_workers=20 + * + * Selectively define the below in order to run tests for them. + */ +defined('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED', false); +defined('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME', false); +defined('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST', false); +defined('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT', false); +defined('TESTS_ZEND_QUEUE_DB_ENABLED') || define('TESTS_ZEND_QUEUE_DB_ENABLED', false); +defined('TESTS_ZEND_QUEUE_DB') || define('TESTS_ZEND_QUEUE_DB', false); +defined('TESTS_ZEND_QUEUE_MEMCACHEQ_ENABLED') || define('TESTS_ZEND_QUEUE_MEMCACHEQ_ENABLED', false); +defined('TESTS_ZEND_QUEUE_MEMCACHEQ_HOST') || define('TESTS_ZEND_QUEUE_MEMCACHEQ_HOST', false); +defined('TESTS_ZEND_QUEUE_MEMCACHEQ_PORT') || define('TESTS_ZEND_QUEUE_MEMCACHEQ_PORT', false); +defined('TESTS_ZEND_QUEUE_PLATFORMJQ_ENABLED') || define('TESTS_ZEND_QUEUE_PLATFORMJQ_ENABLED', false); +defined('TESTS_ZEND_QUEUE_PLATFORMJQ_HOST') || define('TESTS_ZEND_QUEUE_PLATFORMJQ_HOST', false); +defined('TESTS_ZEND_QUEUE_PLATFORMJQ_PASS') || define('TESTS_ZEND_QUEUE_PLATFORMJQ_PASS', false); + + +/** + * Zend\Service\AgileZen online tests + */ +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_ENABLED',false); +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_APIKEY','insert the API key'); +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_PROJECT_ID','insert the project id'); +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_STORY_ID','insert the story id'); +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_INVITE_EMAIL','insert email for invitation'); +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_INVITE_ROLE_ID','insert role id for invitation'); +define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_MEMBER_NAME','insert the member name to add to the project'); + + +/** + * Zend_Service_Amazon online tests + */ +defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID') || define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID', 'Enter AWSAccessKeyId here'); +defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY') || define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY', 'Enter AWSSecretKey here'); +defined('TESTS_ZEND_SERVICE_AMAZON_EC2_IMAGE_ID') || define('TESTS_ZEND_SERVICE_AMAZON_EC2_IMAGE_ID', 'zftestamazonimageid'); +defined('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE') || define('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE', 'us-east-1'); +defined('TESTS_ZEND_SERVICE_AMAZON_EC2_SECURITY_GROUP') || define('TESTS_ZEND_SERVICE_AMAZON_EC2_SECURITY_GROUP', 'default'); +defined('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET') || define('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET', 'zftestamazons3bucket'); +defined('TESTS_ZEND_SERVICE_AMAZON_SQS_QUEUE') || define('TESTS_ZEND_SERVICE_AMAZON_SQS_QUEUE', 'zftestamazonsqsqueuename'); + +/** + * Zend_Service_Delicious tests + */ +defined('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED') || define('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED', false); + +/** + * Zend_Service_DeveloperGarden tests + * Setup your Username and Password to test this Service + */ +defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN') || define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN', 'ZF_Username'); +defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD') || define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD', 'ZF_Password'); + +/** + * Zend_Service_Flickr online tests + */ +defined('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY') || define('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY', 'Enter API key here'); + +/** + * Zend_Service_GoGrid offline tests + */ + +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_KEY') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_KEY','insert key here'); +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SECRET') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SECRET','insert secret here'); +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_NAME') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_NAME','test-zf'); +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IMAGE') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IMAGE','insert image name here'); +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_RAM') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_RAM','insert ram name here'); +defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IP') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IP','insert ip here'); + +/** + * Zend\Service\LiveDocx configuration + * + * Define username and password in order to run unit tests for LiveDocx web services. + * + * phpunit/phpunit will typically work. + */ +defined('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME') || define('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME', false); +defined('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD', false); + +/** + * Zend\Service\LiveDocx premium configuration + * + * Define username, password, WSDL in order to run unit tests for premium LiveDocx web services. + */ +defined('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME', false); +defined('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD', false); +defined('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL', false); + +/** + * Zend_Service_Rackspace tests + */ +defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER', 'Enter key here'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY', 'Enter secret here'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION', 'USA'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME', 'zf-unit-test'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_OBJECT_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_OBJECT_NAME','zf-object-test'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NAME', 'zf-unit-test'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID', '49'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NEW_IMAGEID') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NEW_IMAGEID', '49'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_FLAVORID') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_FLAVORID', '1'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGE_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGE_NAME', 'ZFunitTestImage'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_SHARED_IP_GROUP_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_SHARED_IP_GROUP_NAME', 'ZFgroupIP'); +defined('TESTS_ZEND_SERVICE_RACKSPACE_TIMEOUT') || define('TESTS_ZEND_SERVICE_RACKSPACE_TIMEOUT', 60); + +/** + * Zend_Service_ReCaptcha tests + */ +defined('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED') || define('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED', false); +defined('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY', 'public key'); +defined('TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY', 'private key'); +defined('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY', 'public mailhide key'); +defined('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY', 'private mailhide key'); + +/** + * Zend_Service_Simpy tests + */ +defined('TESTS_ZEND_SERVICE_SIMPY_ENABLED') || define('TESTS_ZEND_SERVICE_SIMPY_ENABLED', false); +defined('TESTS_ZEND_SERVICE_SIMPY_USERNAME') || define('TESTS_ZEND_SERVICE_SIMPY_USERNAME', 'syapizend'); +defined('TESTS_ZEND_SERVICE_SIMPY_PASSWORD') || define('TESTS_ZEND_SERVICE_SIMPY_PASSWORD', 'mgt37ge'); + +/** + * Zend_Service_SlideShare tests + */ +defined('TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME') || define('TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME', ''); +defined('TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD') || define('TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD', ''); +defined('TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET') || define('TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET', ''); +defined('TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY') || define('TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY', ''); + +// The slide show ID to retrieve during tests +defined('TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID') || define('TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID', 0); + +// The tag to retrieve during tests +defined('TESTS_ZEND_SERVICE_SLIDESHARE_TAG') || define('TESTS_ZEND_SERVICE_SLIDESHARE_TAG', 'zend'); + +// The group to retrieve during tests +defined('TESTS_ZEND_SERVICE_SLIDESHARE_GROUP') || define('TESTS_ZEND_SERVICE_SLIDESHARE_GROUP', ''); + +/** + * Zend_Service_Twitter tests + * + * ONLINE_ENABLED indicates whether or not to run tests requiring a network + * connection. + * + * TWITTER_USER and TWITTER_PASS are valid Twitter credentials you wish to use + * when testing. + */ +defined('TESTS_ZEND_SERVICE_TWITTER_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_TWITTER_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_TWITTER_USER') || define('TESTS_ZEND_SERVICE_TWITTER_USER', 'zftestuser'); +defined('TESTS_ZEND_SERVICE_TWITTER_PASS') || define('TESTS_ZEND_SERVICE_TWITTER_PASS', 'zftestuser'); + +/** + * Zend_Service_WindowsAzure tests + */ + +/** + * Online + */ + +define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTNAME',''); +define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTKEY',''); +define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_TABLE_HOST',''); +define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_HOST',''); +define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_PORT',''); +define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_CREDENTIALS',''); + +/** + * Proxy settings + */ +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_USEPROXY') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_USEPROXY', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY', ''); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_PORT') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_PORT', '8080'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_CREDENTIALS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_CREDENTIALS', ''); + +/** + * Azure hosts + */ +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_DEV', '127.0.0.1:10000'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_DEV', '127.0.0.1:10001'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_DEV', '127.0.0.1:10002'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_PROD', 'blob.core.windows.net'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_PROD', 'queue.core.windows.net'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_PROD', 'table.core.windows.net'); + +/** + * Credentials + */ +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_DEV', 'devstoreaccount1'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_DEV', 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_PROD', 'phpazure'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_PROD', 'I+ebYPcIDB6BsmfAe6pJSpOw8oXA6jMBZv1BEZcSPRqTpldt44refCl65YpKJqcBOiD21Lxsj8d6Ah8Oc2/gKA=='); + +/** + * Blob storage tests + */ +// Enable this tests only when you have a working account +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNTESTS', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNONPROD', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNLARGEBLOB') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNLARGEBLOB', true); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_CONTAINER_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_CONTAINER_PREFIX', 'phpazuretestblob'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSTREAM_CONTAINER_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSTREAM_CONTAINER_PREFIX', 'phpazureteststream'); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSA_CONTAINER_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSA_CONTAINER_PREFIX', 'phpazuretestshared'); + +/** + * Table storage tests + */ +// Enable this tests only when you have a working account +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNTESTS', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNONPROD', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_TABLENAME_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_TABLENAME_PREFIX', 'phpazuretesttable'); + +/** + * Queue storage tests + */ +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNTESTS', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNONPROD', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_PREFIX', 'phpazuretestqueue'); + +/** + * SessionHandler tests + */ +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNTESTS', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNONPROD', false); +defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_TABLENAME_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_TABLENAME_PREFIX', 'phpazuretestsession'); + +/** + * Zend_Service_Yahoo online tests + */ +defined('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED', false); +defined('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID') || define('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID', 'Enter APPID here'); + +/** + * Zend_Soap_AutoDiscover scenario tests for complex objects and wsdl generation + * + * Copy all the files of zf/tests/Zend/Soap/_files/fulltests into a directory + * that can be reached by webserver and enter the base uri to this directory + * into the variable. The test "Zend_Soap_AutoDiscover_OnlineTest" makes use + * of the servers and AutoDiscover feature. + * + * NOTE: Make sure the servers are using the correct Zend Framework copy, + * when having more than one version installed and include paths are changing. + */ +defined('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') || define('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI', false); + +/** + * Zend_Uri tests + * + * Setting CRASH_TEST_ENABLED to true will enable some tests that may + * potentially crash PHP on some systems, due to very deep-nesting regular + * expressions. + * + * Only do this if you know what you are doing! + */ +defined('TESTS_ZEND_URI_CRASH_TEST_ENABLED') || define('TESTS_ZEND_URI_CRASH_TEST_ENABLED', false); + +/** + * Zend_Validate tests + * + * Set ONLINE_ENABLED if you wish to run validators that require network + * connectivity. + */ +defined('TESTS_ZEND_VALIDATE_ONLINE_ENABLED') || define('TESTS_ZEND_VALIDATE_ONLINE_ENABLED', false); + +/** + * PHPUnit Code Coverage / Test Report + */ +defined('TESTS_GENERATE_REPORT') || define('TESTS_GENERATE_REPORT', false); +defined('TESTS_GENERATE_REPORT_TARGET') || define('TESTS_GENERATE_REPORT_TARGET', '/path/to/target'); + From 5f3b58f936a4eab6209757db1566d497ef71577d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 4 Apr 2012 00:32:21 +0200 Subject: [PATCH 090/123] Making the run-tests.sh script executable --- .travis/run-tests.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .travis/run-tests.sh diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh old mode 100644 new mode 100755 From 44951ed45978444e246826733d522b8a9031b930 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 4 Apr 2012 20:56:26 +0200 Subject: [PATCH 091/123] Moving travis test configuration This way it is more obvious to the committer changing test configuration that also travis config should be changed --- .travis/TestConfiguration.php | 825 ---------------------------------- 1 file changed, 825 deletions(-) delete mode 100644 .travis/TestConfiguration.php diff --git a/.travis/TestConfiguration.php b/.travis/TestConfiguration.php deleted file mode 100644 index fd894704..00000000 --- a/.travis/TestConfiguration.php +++ /dev/null @@ -1,825 +0,0 @@ - test disabling output buffering in - * dispatcher - */ -defined('TESTS_ZEND_CONTROLLER_DISPATCHER_OB') || define('TESTS_ZEND_CONTROLLER_DISPATCHER_OB', false); - -/** - * Zend_Crypt related constantes - * - * TESTS_ZEND_CRYPT_OPENSSL_CONF => location of an openssl.cnf file for use - * with RSA encryption - */ -defined('TESTS_ZEND_CRYPT_OPENSSL_CONF') || define('TESTS_ZEND_CRYPT_OPENSSL_CONF', false); - -/** - * Zend_Db_Adapter_Pdo_Mysql and Zend_Db_Adapter_Mysqli - * - * There are separate properties to enable tests for the PDO_MYSQL adapter and - * the native Mysqli adapters, but the other properties are shared between the - * two MySQL-related Zend_Db adapters. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE', 'test'); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT', 3306); - -/** - * Zend_Db_Adapter_Pdo_Sqlite - * - * Username and password are irrelevant for SQLite. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE', ':memory:'); - -/** - * Zend_Db_Adapter_Pdo_Mssql - * - * Note that you need to patch your ntwdblib.dll, the one that - * comes with PHP does not work. See user comments at - * http://us2.php.net/manual/en/ref.mssql.php - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE', 'test'); - -/** - * Zend_Db_Adapter_Pdo_Pgsql - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE', 'postgres'); - -/** - * Zend_Db_Adapter_Oracle and Zend_Db_Adapter_Pdo_Oci - * - * There are separate properties to enable tests for the PDO_OCI adapter and - * the native Oracle adapter, but the other properties are shared between the - * two Oracle-related Zend_Db adapters. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_SID') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_SID', 'xe'); - -/** - * Zend_Db_Adapter_Db2 and Zend_Db_Adapter_Pdo_Ibm - * There are separate properties to enable tests for the PDO_IBM adapter and - * the native DB2 adapter, but the other properties are shared between the - * two related Zend_Db adapters. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_DB2_PORT') || define('TESTS_ZEND_DB_ADAPTER_DB2_PORT', 50000); -defined('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE', 'sample'); - -/** - * Zend_Db_Adapter_Sqlsrv - * Note: Make sure that you create the "test" database and set a - * username and password - * - */ -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME', 'localhost\SQLEXPRESS'); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE', 'test'); - -/** - * Zend_Feed_Reader tests - * - * If the ONLINE_ENABLED property is false, only tests that can be executed - * without network connectivity are run; when enabled, all tests will run. - */ -defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED') || define('TESTS_ZEND_FEED_READER_ONLINE_ENABLED', false); - -/** - * Zend_Gdata tests - * - * If the ONLINE_ENABLED property is false, only tests that can be executed with - * a mock HTTP client are run. No request is sent to the Google Gdata servers. - * If ONLINE_ENABLED is true, some tests may make requests to the remote - * servers. This does not work if you are running tests on a disconnected - * client host. Also, the tests may show as failures if the Google servers - * cannot be reached or if they do not respond for another reason. - * - * If the CLIENTLOGIN_ENABLED property below is false, the authenticated - * tests are reported Skipped in the test run. Set this property to true - * to enable tests that require ClientLogin authentication. Enter your - * Google login credentials in the EMAIL and PASSWORD properties below. - * - * Edit TestConfiguration.php, not TestConfiguration.php.dist. - * Never commit plaintext passwords to the source code repository. - * - * Note: the GData tests currently require that the TZID env variable - * be set or the timezone otherwise configured. You'll see errors from the - * tests if this is not the case. - */ -defined('TESTS_ZEND_GDATA_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_ONLINE_ENABLED', false); -defined('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED') || define('TESTS_ZEND_GDATA_CLIENTLOGIN_ENABLED', false); - -/* - * The credentials provided here should be only for a TEST account. - * Data for various services in this account may be added to, updated, - * or deleted based upon the actions of these test accounts. - */ -defined('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL') || define('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL', 'example@example.com'); -defined('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD') || define('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD', 'password'); - -/* - * This is the ID of a blank blog. There is no need to have - * any content in this blog. Also, blogs can only be used - * several times for the purpose of these test cases before - * they must be deleted and recreated. Otherwise, the tests - * will start failing, as posts to Blogger will return a 201 Created - * response even though the entry was not posted to the blog. - * This problem is being investigated. - */ -defined('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_BLOGGER_ONLINE_ENABLED', false); -defined('TESTS_ZEND_GDATA_BLOG_ID') || define('TESTS_ZEND_GDATA_BLOG_ID', '1111111111111111111'); - -/* - * This is the key for a spreadsheet with data only in the first row of - * the spreadsheet. The strings 'a1', 'b1', 'c1', 'd1' should be in the - * corresponding cell locations. - */ -defined('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_SPREADSHEETS_ONLINE_ENABLED', false); -defined('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY') || define('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY', 'o01111111111111111111.1111111111111111111'); -defined('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID') || define('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID', 'default'); - -/* - * This indicates that online tests for the Google Calendar API should - * be performed. The default calendar will be used. - */ -defined('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_CALENDAR_ONLINE_ENABLED', false); - -/* - * This is the fully-qualified domain name for a domiain hosted using - * Google Apps. This domain must be registered with Google Apps and - * have API access enabled. This should be a TEST domain only. - */ -defined('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_GAPPS_ONLINE_ENABLED', false); -defined('TESTS_ZEND_GDATA_GAPPS_DOMAIN') || define('TESTS_ZEND_GDATA_GAPPS_DOMAIN', 'example.com.invalid'); -defined('TESTS_ZEND_GDATA_GAPPS_EMAIL') || define('TESTS_ZEND_GDATA_GAPPS_EMAIL', 'example@example.com'); -defined('TESTS_ZEND_GDATA_GAPPS_PASSWORD') || define('TESTS_ZEND_GDATA_GAPPS_PASSWORD', 'password'); - -/* - * This is the ONLINE_ENABLED property for Google Base. - */ -defined('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_GBASE_ONLINE_ENABLED', false); - -/* - * This indicates that online tests for the Books Search data API - * should be performed. - */ -defined('TESTS_ZEND_GDATA_BOOKS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_BOOKS_ONLINE_ENABLED', false); - -/* - * This indicates that online tests for the YouTube data API should - * be performed. - */ -defined('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_YOUTUBE_ONLINE_ENABLED', false); - -/* - * This is the username to use for retrieving subscriptions, etc - */ -defined('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT') || define('TESTS_ZEND_GDATA_YOUTUBE_ACCOUNT', 'zfgdata'); - -/* - * This is the developer key to access the YouTube API - */ -defined('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY') || define('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY', 'your_developer_key_here'); - -/* - * This is the client ID to access the YouTube API - */ -defined('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID') || define('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID', 'ZF_UnitTests_unknown'); - -/* - * This indicates that online tests for the Google Documents API should - * be performed. - */ -defined('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_DOCS_ONLINE_ENABLED', false); - -/* - * This indicates that online tests for the GData Photos API should - * be performed. - */ -defined('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_PHOTOS_ONLINE_ENABLED', false); - -/* - * This indicates that online tests for the Google Health API should - * be performed. - */ -defined('TESTS_ZEND_GDATA_HEALTH_ONLINE_ENABLED') || define('TESTS_ZEND_GDATA_HEALTH_ONLINE_ENABLED', false); - -/** - * Zend_Http_Client tests - * - * To enable the dynamic Zend_Http_Client tests, you will need to symbolically - * link or copy the files in tests/Zend/Http/Client/_files to a directory - * under your web server(s) document root and set this constant to point to the - * URL of this directory. - */ -defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') || define('TESTS_ZEND_HTTP_CLIENT_BASEURI', false); - -/** - * Zend_Http_Client_Proxy tests - * - * HTTP proxy to be used for testing the Proxy adapter. Set to a string of - * the form 'host:port'. Set to null to skip HTTP proxy tests. - */ -defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY', false); -defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER', ''); -defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS', ''); - -/** - * Zend_Loader_Autoloader multi-version support tests - * - * ENABLED: whether or not to run the multi-version tests - * PATH: path to a directory containing multiple ZF version installs - * LATEST: most recent ZF version in the PATH - * e.g., "1.9.2" - * LATEST_MAJOR: most recent ZF major version in the PATH to test against - * e.g., "1.9.2" - * LATEST_MINOR: most recent ZF minor version in the PATH to test against - * e.g., "1.8.4PL1" - * SPECIFIC: specific ZF version in the PATH to test against - * e.g., "1.7.6" - * As an example, consider the following tree: - * ZendFramework/ - * |-- 1.9.2 - * |-- ZendFramework-1.9.1-minimal - * |-- 1.8.4PL1 - * |-- 1.8.4 - * |-- ZendFramework-1.8.3 - * |-- 1.7.8 - * |-- 1.7.7 - * |-- 1.7.6 - * You would then set the value of "LATEST" and "LATEST_MAJOR" to "1.9.2", and - * could choose between "1.9.2", "1.8.4PL1", and "1.7.8" for "LATEST_MINOR", - * and any version number for "SPECIFIC". "PATH" would point to the parent - * "ZendFramework" directory. - */ -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_ENABLED') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_ENABLED', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_PATH') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_PATH', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MAJOR') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MAJOR', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MINOR') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MINOR', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_SPECIFIC') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_SPECIFIC', false); - -/** - * Zend_Ldap online tests - */ -defined('TESTS_ZEND_LDAP_ONLINE_ENABLED') || define('TESTS_ZEND_LDAP_ONLINE_ENABLED', false); - -/* These largely map to the options described in the Zend_Ldap and - * Zend_Auth_Adapter_Ldap documentation. - * - * Example Configuration for Active Directory: - * HOST: dc1.w.net - * USE_START_TLS: true - * USE_SSL: false - * USERNAME: CN=User 1,CN=Users,DC=w,DC=net - * PRINCIPAL_NAME: user1@w.net - * LDAP_PASSWORD: pass1 - * BASE_DN: CN=Users,DC=w,DC=net - * DOMAIN_NAME: w.net - * ACCOUNT_DOMAIN_NAME_SHORT: W - * ALT_USERNAME: user2 - * ALT_DN: CN=User 2,CN=Users,DC=w,DC=net - * ALT_PASSWORD: pass2 - * - * Example Configuration for OpenLDAP - * HOST: s0.foo.net - * USERNAME: CN=user1,DC=foo,DC=net - * PRINCIPAL_NAME: user1@foo.net - * LDAP_PASSWORD: pass1 - * BIND_REQUIRES_DN: true - * BASE_DN: OU=Sales,DC=w,DC=net - * DOMAIN_NAME: foo.net - * ACCOUNT_DOMAIN_NAME_SHORT: FOO - * ALT_USERNAME: abaker - * ALT_DN: CN=Alice Baker,OU=Sales,DC=foo,DC=net - * ALT_PASSWORD: apass - */ -defined('TESTS_ZEND_LDAP_HOST') || define('TESTS_ZEND_LDAP_HOST', 'localhost'); -//defined('TESTS_ZEND_LDAP_PORT') || define('TESTS_ZEND_LDAP_PORT', 389); -defined('TESTS_ZEND_LDAP_USE_START_TLS') || define('TESTS_ZEND_LDAP_USE_START_TLS', true); -//defined('TESTS_ZEND_LDAP_USE_SSL') || define('TESTS_ZEND_LDAP_USE_SSL', false); -defined('TESTS_ZEND_LDAP_USERNAME') || define('TESTS_ZEND_LDAP_USERNAME', 'CN=someUser,DC=example,DC=com'); -defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', 'someUser@example.com'); -defined('TESTS_ZEND_LDAP_PASSWORD') || define('TESTS_ZEND_LDAP_PASSWORD', null); -defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') || define('TESTS_ZEND_LDAP_BIND_REQUIRES_DN', true); -defined('TESTS_ZEND_LDAP_BASE_DN') || define('TESTS_ZEND_LDAP_BASE_DN', 'OU=Sales,DC=example,DC=com'); -//defined('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') || define('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT', '(&(objectClass=posixAccount)(uid=%s))'); -defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME', 'example.com'); -defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT', 'EXAMPLE'); -defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', 'anotherUser'); -defined('TESTS_ZEND_LDAP_ALT_DN') || define('TESTS_ZEND_LDAP_ALT_DN', 'CN=Another User,OU=Sales,DC=example,DC=com'); -defined('TESTS_ZEND_LDAP_ALT_PASSWORD') || define('TESTS_ZEND_LDAP_ALT_PASSWORD', null); // Used in Zend_Auth_Adapter_Ldap tests -//(defined('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE') || define('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE', 'OU=Test,OU=Sales,DC=example,DC=com'); - -/** - * Zend_Locale tests - * - * If the TESTS_ZEND_LOCALE_FORMAT_SETLOCALE property below is a valid, - * locally recognized locale (try "locale -a"), then all tests in - * tests/Zend/Locale/ test suites will execute *after* - * setlocale(LC_ALL, TESTS_ZEND_LOCALE_FORMAT_SETLOCALE); - * Primarily, this switches certain PHP functions to emit "localized" output, - * including the built-in "to string" for integer and float conversions. - * Thus, a locale of 'fr_FR' yields number-to-string conversions in a - * localized form with the decimal place separator chosen via: - * setlocale(LC_ALL, 'fr_FR@euro'); - */ -//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr'); -//define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', 'fr_FR@euro'); -defined('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE') || define('TESTS_ZEND_LOCALE_FORMAT_SETLOCALE', false); - -/** - * Zend_Date tests - * - * If the BCMATH_ENABLED property below is false, all arithmetic - * operations will use ordinary PHP math operators and functions. - * Otherwise, the bcmath functions will be used for unlimited precision. - * - * If the EXTENDED_COVERAGE property below is false, most of the I18N - * unit tests will not be computed... this speeds tests up to 80 minutes - * when doing reports. * - * Edit TestConfiguration.php, not TestConfiguration.php.dist. - */ -defined('TESTS_ZEND_LOCALE_BCMATH_ENABLED') || define('TESTS_ZEND_LOCALE_BCMATH_ENABLED', true); -defined('TESTS_ZEND_I18N_EXTENDED_COVERAGE') || define('TESTS_ZEND_I18N_EXTENDED_COVERAGE', true); - -/** - * Zend_Mail_Storage tests - * - * TESTS_ZEND_MAIL_SERVER_TESTDIR and TESTS_ZEND_MAIL_SERVER_FORMAT are used for POP3 and IMAP tests. - * TESTS_ZEND_MAIL_SERVER_FORMAT is the format your test mail server uses: 'mbox' or 'maildir'. The mail - * storage for the user specified in your POP3 or IMAP tests should be TESTS_ZEND_MAIL_SERVER_TESTDIR. Be - * careful: it's cleared before copying the files. If you want to copy the files manually set the dir - * to null (or anything == null). - * - * TESTS_ZEND_MAIL_TEMPDIR is used for testing write operations in local storages. If not set (== null) - * tempnam() is used. - */ -defined('TESTS_ZEND_MAIL_SERVER_TESTDIR') || define('TESTS_ZEND_MAIL_SERVER_TESTDIR', null); -defined('TESTS_ZEND_MAIL_SERVER_FORMAT') || define('TESTS_ZEND_MAIL_SERVER_FORMAT', 'mbox'); -defined('TESTS_ZEND_MAIL_TEMPDIR') || define('TESTS_ZEND_MAIL_TEMPDIR', null); - -/** - * Zend_Mail_Storage_Pop3 / Zend_Mail_Transport_Pop3 - * - * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail - * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR - */ -defined('TESTS_ZEND_MAIL_POP3_ENABLED') || define('TESTS_ZEND_MAIL_POP3_ENABLED', false); -defined('TESTS_ZEND_MAIL_POP3_HOST') || define('TESTS_ZEND_MAIL_POP3_HOST', 'localhost'); -defined('TESTS_ZEND_MAIL_POP3_USER') || define('TESTS_ZEND_MAIL_POP3_USER', 'test'); -defined('TESTS_ZEND_MAIL_POP3_PASSWORD') || define('TESTS_ZEND_MAIL_POP3_PASSWORD', ''); -// test SSL connections if enabled in your test server -defined('TESTS_ZEND_MAIL_POP3_SSL') || define('TESTS_ZEND_MAIL_POP3_SSL', true); -defined('TESTS_ZEND_MAIL_POP3_TLS') || define('TESTS_ZEND_MAIL_POP3_TLS', true); -// WRONG_PORT should be an existing server port, -// INVALID_PORT should be a non existing (each on defined host) -defined('TESTS_ZEND_MAIL_POP3_WRONG_PORT') || define('TESTS_ZEND_MAIL_POP3_WRONG_PORT', 80); -defined('TESTS_ZEND_MAIL_POP3_INVALID_PORT') || define('TESTS_ZEND_MAIL_POP3_INVALID_PORT', 3141); - -/** - * Zend_Mail_Storage_Imap / Zend_Mail_Transport_Imap - * - * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail - * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR - */ -defined('TESTS_ZEND_MAIL_IMAP_ENABLED') || define('TESTS_ZEND_MAIL_IMAP_ENABLED', false); -defined('TESTS_ZEND_MAIL_IMAP_HOST') || define('TESTS_ZEND_MAIL_IMAP_HOST', 'localhost'); -defined('TESTS_ZEND_MAIL_IMAP_USER') || define('TESTS_ZEND_MAIL_IMAP_USER', 'test'); -defined('TESTS_ZEND_MAIL_IMAP_PASSWORD') || define('TESTS_ZEND_MAIL_IMAP_PASSWORD', ''); -// test SSL connections if enabled in your test server -defined('TESTS_ZEND_MAIL_IMAP_SSL') || define('TESTS_ZEND_MAIL_IMAP_SSL', true); -defined('TESTS_ZEND_MAIL_IMAP_TLS') || define('TESTS_ZEND_MAIL_IMAP_TLS', true); -// WRONG_PORT should be an existing server port, -// INVALID_PORT should be a non-existing (each on defined host) -defined('TESTS_ZEND_MAIL_IMAP_WRONG_PORT') || define('TESTS_ZEND_MAIL_IMAP_WRONG_PORT', 80); -defined('TESTS_ZEND_MAIL_IMAP_INVALID_PORT') || define('TESTS_ZEND_MAIL_IMAP_INVALID_PORT', 3141); - - -/** - * Zend_Mail_Storage_Maildir test - * - * Before enabling this test you have to unpack messages.tar in - * Zend/Mail/_files/test.maildir/cur/ and remove the tar for this test to work. - * That's because the messages files have a colon in the filename and that's a - * forbidden character on Windows. - */ -defined('TESTS_ZEND_MAIL_MAILDIR_ENABLED') || define('TESTS_ZEND_MAIL_MAILDIR_ENABLED', false); - -/** - * Zend_Mail_Transport_Smtp - * - * @todo TO be implemented - */ -defined('TESTS_ZEND_MAIL_SMTP_ENABLED') || define('TESTS_ZEND_MAIL_SMTP_ENABLED', false); -defined('TESTS_ZEND_MAIL_SMTP_HOST') || define('TESTS_ZEND_MAIL_SMTP_HOST', 'localhost'); -defined('TESTS_ZEND_MAIL_SMTP_PORT') || define('TESTS_ZEND_MAIL_SMTP_PORT', 25); -defined('TESTS_ZEND_MAIL_SMTP_USER') || define('TESTS_ZEND_MAIL_SMTP_USER', 'testuser'); -defined('TESTS_ZEND_MAIL_SMTP_PASSWORD') || define('TESTS_ZEND_MAIL_SMTP_PASSWORD', 'testpassword'); -defined('TESTS_ZEND_MAIL_SMTP_AUTH') || define('TESTS_ZEND_MAIL_SMTP_AUTH', false); -// AUTH can be set to false or a string of AUTH method (e.g. LOGIN, PLAIN, CRAMMD5 or DIGESTMD5) - -/** - * Zend_Queue Test Configuration constants - * - * The Zend_Queue_Adapter_Db constant should be a JSON-encoded string - * representing a configuration object for Zend_Db::factory(). For example: - * { - * type: "pdo_mysql", - * host: "127.0.0.1", - * port: 3306, - * username: "queue", - * password: "queue", - * dbname: "queue" - * } - * - * The PlatformJobQueue adapter expects two parameters, the host and password. - * The HOST string should include both the host and port (typically 10003): - * 127.0.0.1:10003 - * When running tests against PlatformJobQueue, it's best to do so where - * Platform is installed on localhost and has maximum workers set to 20 - * (default is 5); do so with this zend.ini setting: - * zend_jq.max_num_of_request_workers=20 - * - * Selectively define the below in order to run tests for them. - */ -defined('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED', false); -defined('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME', false); -defined('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST', false); -defined('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT') || define('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT', false); -defined('TESTS_ZEND_QUEUE_DB_ENABLED') || define('TESTS_ZEND_QUEUE_DB_ENABLED', false); -defined('TESTS_ZEND_QUEUE_DB') || define('TESTS_ZEND_QUEUE_DB', false); -defined('TESTS_ZEND_QUEUE_MEMCACHEQ_ENABLED') || define('TESTS_ZEND_QUEUE_MEMCACHEQ_ENABLED', false); -defined('TESTS_ZEND_QUEUE_MEMCACHEQ_HOST') || define('TESTS_ZEND_QUEUE_MEMCACHEQ_HOST', false); -defined('TESTS_ZEND_QUEUE_MEMCACHEQ_PORT') || define('TESTS_ZEND_QUEUE_MEMCACHEQ_PORT', false); -defined('TESTS_ZEND_QUEUE_PLATFORMJQ_ENABLED') || define('TESTS_ZEND_QUEUE_PLATFORMJQ_ENABLED', false); -defined('TESTS_ZEND_QUEUE_PLATFORMJQ_HOST') || define('TESTS_ZEND_QUEUE_PLATFORMJQ_HOST', false); -defined('TESTS_ZEND_QUEUE_PLATFORMJQ_PASS') || define('TESTS_ZEND_QUEUE_PLATFORMJQ_PASS', false); - - -/** - * Zend\Service\AgileZen online tests - */ -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_ENABLED',false); -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_APIKEY','insert the API key'); -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_PROJECT_ID','insert the project id'); -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_STORY_ID','insert the story id'); -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_INVITE_EMAIL','insert email for invitation'); -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_INVITE_ROLE_ID','insert role id for invitation'); -define('TESTS_ZEND_SERVICE_AGILEZEN_ONLINE_MEMBER_NAME','insert the member name to add to the project'); - - -/** - * Zend_Service_Amazon online tests - */ -defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID') || define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID', 'Enter AWSAccessKeyId here'); -defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY') || define('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY', 'Enter AWSSecretKey here'); -defined('TESTS_ZEND_SERVICE_AMAZON_EC2_IMAGE_ID') || define('TESTS_ZEND_SERVICE_AMAZON_EC2_IMAGE_ID', 'zftestamazonimageid'); -defined('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE') || define('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE', 'us-east-1'); -defined('TESTS_ZEND_SERVICE_AMAZON_EC2_SECURITY_GROUP') || define('TESTS_ZEND_SERVICE_AMAZON_EC2_SECURITY_GROUP', 'default'); -defined('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET') || define('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET', 'zftestamazons3bucket'); -defined('TESTS_ZEND_SERVICE_AMAZON_SQS_QUEUE') || define('TESTS_ZEND_SERVICE_AMAZON_SQS_QUEUE', 'zftestamazonsqsqueuename'); - -/** - * Zend_Service_Delicious tests - */ -defined('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED') || define('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED', false); - -/** - * Zend_Service_DeveloperGarden tests - * Setup your Username and Password to test this Service - */ -defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN') || define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN', 'ZF_Username'); -defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD') || define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD', 'ZF_Password'); - -/** - * Zend_Service_Flickr online tests - */ -defined('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_FLICKR_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY') || define('TESTS_ZEND_SERVICE_FLICKR_ONLINE_APIKEY', 'Enter API key here'); - -/** - * Zend_Service_GoGrid offline tests - */ - -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_KEY') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_KEY','insert key here'); -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SECRET') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SECRET','insert secret here'); -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_NAME') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_NAME','test-zf'); -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IMAGE') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IMAGE','insert image name here'); -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_RAM') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_RAM','insert ram name here'); -defined('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IP') || define('TESTS_ZEND_SERVICE_GOGRID_ONLINE_SERVER_IP','insert ip here'); - -/** - * Zend\Service\LiveDocx configuration - * - * Define username and password in order to run unit tests for LiveDocx web services. - * - * phpunit/phpunit will typically work. - */ -defined('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME') || define('TESTS_ZEND_SERVICE_LIVEDOCX_USERNAME', false); -defined('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PASSWORD', false); - -/** - * Zend\Service\LiveDocx premium configuration - * - * Define username, password, WSDL in order to run unit tests for premium LiveDocx web services. - */ -defined('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_USERNAME', false); -defined('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_PASSWORD', false); -defined('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL') || define('TESTS_ZEND_SERVICE_LIVEDOCX_PREMIUM_WSDL', false); - -/** - * Zend_Service_Rackspace tests - */ -defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER', 'Enter key here'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY', 'Enter secret here'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION') || define('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION', 'USA'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME', 'zf-unit-test'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_OBJECT_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_OBJECT_NAME','zf-object-test'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NAME', 'zf-unit-test'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGEID', '49'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NEW_IMAGEID') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_NEW_IMAGEID', '49'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_FLAVORID') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_FLAVORID', '1'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGE_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_IMAGE_NAME', 'ZFunitTestImage'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_SHARED_IP_GROUP_NAME') || define('TESTS_ZEND_SERVICE_RACKSPACE_SERVER_SHARED_IP_GROUP_NAME', 'ZFgroupIP'); -defined('TESTS_ZEND_SERVICE_RACKSPACE_TIMEOUT') || define('TESTS_ZEND_SERVICE_RACKSPACE_TIMEOUT', 60); - -/** - * Zend_Service_ReCaptcha tests - */ -defined('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED') || define('TESTS_ZEND_SERVICE_RECAPTCHA_ENABLED', false); -defined('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_RECAPTCHA_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_PUBLIC_KEY', 'public key'); -defined('TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_PRIVATE_KEY', 'private key'); -defined('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PUBLIC_KEY', 'public mailhide key'); -defined('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY') || define('TESTS_ZEND_SERVICE_RECAPTCHA_MAILHIDE_PRIVATE_KEY', 'private mailhide key'); - -/** - * Zend_Service_Simpy tests - */ -defined('TESTS_ZEND_SERVICE_SIMPY_ENABLED') || define('TESTS_ZEND_SERVICE_SIMPY_ENABLED', false); -defined('TESTS_ZEND_SERVICE_SIMPY_USERNAME') || define('TESTS_ZEND_SERVICE_SIMPY_USERNAME', 'syapizend'); -defined('TESTS_ZEND_SERVICE_SIMPY_PASSWORD') || define('TESTS_ZEND_SERVICE_SIMPY_PASSWORD', 'mgt37ge'); - -/** - * Zend_Service_SlideShare tests - */ -defined('TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME') || define('TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME', ''); -defined('TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD') || define('TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD', ''); -defined('TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET') || define('TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET', ''); -defined('TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY') || define('TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY', ''); - -// The slide show ID to retrieve during tests -defined('TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID') || define('TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID', 0); - -// The tag to retrieve during tests -defined('TESTS_ZEND_SERVICE_SLIDESHARE_TAG') || define('TESTS_ZEND_SERVICE_SLIDESHARE_TAG', 'zend'); - -// The group to retrieve during tests -defined('TESTS_ZEND_SERVICE_SLIDESHARE_GROUP') || define('TESTS_ZEND_SERVICE_SLIDESHARE_GROUP', ''); - -/** - * Zend_Service_Twitter tests - * - * ONLINE_ENABLED indicates whether or not to run tests requiring a network - * connection. - * - * TWITTER_USER and TWITTER_PASS are valid Twitter credentials you wish to use - * when testing. - */ -defined('TESTS_ZEND_SERVICE_TWITTER_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_TWITTER_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_TWITTER_USER') || define('TESTS_ZEND_SERVICE_TWITTER_USER', 'zftestuser'); -defined('TESTS_ZEND_SERVICE_TWITTER_PASS') || define('TESTS_ZEND_SERVICE_TWITTER_PASS', 'zftestuser'); - -/** - * Zend_Service_WindowsAzure tests - */ - -/** - * Online - */ - -define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTNAME',''); -define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTKEY',''); -define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_TABLE_HOST',''); -define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_HOST',''); -define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_PORT',''); -define('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_CREDENTIALS',''); - -/** - * Proxy settings - */ -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_USEPROXY') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_USEPROXY', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY', ''); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_PORT') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_PORT', '8080'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_CREDENTIALS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_CREDENTIALS', ''); - -/** - * Azure hosts - */ -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_DEV', '127.0.0.1:10000'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_DEV', '127.0.0.1:10001'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_DEV', '127.0.0.1:10002'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_HOST_PROD', 'blob.core.windows.net'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_HOST_PROD', 'queue.core.windows.net'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_PROD', 'table.core.windows.net'); - -/** - * Credentials - */ -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_DEV', 'devstoreaccount1'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_DEV') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_DEV', 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_PROD', 'phpazure'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_PROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_PROD', 'I+ebYPcIDB6BsmfAe6pJSpOw8oXA6jMBZv1BEZcSPRqTpldt44refCl65YpKJqcBOiD21Lxsj8d6Ah8Oc2/gKA=='); - -/** - * Blob storage tests - */ -// Enable this tests only when you have a working account -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNTESTS', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNONPROD', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNLARGEBLOB') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_RUNLARGEBLOB', true); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_CONTAINER_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOB_CONTAINER_PREFIX', 'phpazuretestblob'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSTREAM_CONTAINER_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSTREAM_CONTAINER_PREFIX', 'phpazureteststream'); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSA_CONTAINER_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_BLOBSA_CONTAINER_PREFIX', 'phpazuretestshared'); - -/** - * Table storage tests - */ -// Enable this tests only when you have a working account -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNTESTS', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_RUNONPROD', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_TABLENAME_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_TABLENAME_PREFIX', 'phpazuretesttable'); - -/** - * Queue storage tests - */ -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNTESTS', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_RUNONPROD', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_QUEUE_PREFIX', 'phpazuretestqueue'); - -/** - * SessionHandler tests - */ -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNTESTS') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNTESTS', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNONPROD') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNONPROD', false); -defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_TABLENAME_PREFIX') || define('TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_TABLENAME_PREFIX', 'phpazuretestsession'); - -/** - * Zend_Service_Yahoo online tests - */ -defined('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED') || define('TESTS_ZEND_SERVICE_YAHOO_ONLINE_ENABLED', false); -defined('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID') || define('TESTS_ZEND_SERVICE_YAHOO_ONLINE_APPID', 'Enter APPID here'); - -/** - * Zend_Soap_AutoDiscover scenario tests for complex objects and wsdl generation - * - * Copy all the files of zf/tests/Zend/Soap/_files/fulltests into a directory - * that can be reached by webserver and enter the base uri to this directory - * into the variable. The test "Zend_Soap_AutoDiscover_OnlineTest" makes use - * of the servers and AutoDiscover feature. - * - * NOTE: Make sure the servers are using the correct Zend Framework copy, - * when having more than one version installed and include paths are changing. - */ -defined('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') || define('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI', false); - -/** - * Zend_Uri tests - * - * Setting CRASH_TEST_ENABLED to true will enable some tests that may - * potentially crash PHP on some systems, due to very deep-nesting regular - * expressions. - * - * Only do this if you know what you are doing! - */ -defined('TESTS_ZEND_URI_CRASH_TEST_ENABLED') || define('TESTS_ZEND_URI_CRASH_TEST_ENABLED', false); - -/** - * Zend_Validate tests - * - * Set ONLINE_ENABLED if you wish to run validators that require network - * connectivity. - */ -defined('TESTS_ZEND_VALIDATE_ONLINE_ENABLED') || define('TESTS_ZEND_VALIDATE_ONLINE_ENABLED', false); - -/** - * PHPUnit Code Coverage / Test Report - */ -defined('TESTS_GENERATE_REPORT') || define('TESTS_GENERATE_REPORT', false); -defined('TESTS_GENERATE_REPORT_TARGET') || define('TESTS_GENERATE_REPORT_TARGET', '/path/to/target'); - From 57d51b885baa77febbc4a37e5184a3a2b60808e0 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 4 Apr 2012 21:28:23 +0200 Subject: [PATCH 092/123] Re-enabling components as of @weierophinney suggestions --- .travis/skipped-components | 16 ---------------- .travis/tested-components | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.travis/skipped-components b/.travis/skipped-components index 7d38e2de..6ccd1be1 100644 --- a/.travis/skipped-components +++ b/.travis/skipped-components @@ -1,27 +1,11 @@ Zend/Amf Zend/Barcode -Zend/Cache -Zend/Code Zend/Date -Zend/Docbook Zend/Feed -Zend/File -Zend/Filter -Zend/GData -Zend/Json -Zend/Locale -Zend/Mail -Zend/Mime -Zend/Navigation -Zend/OpenId Zend/Paginator Zend/Queue -Zend/RegistryTest.php Zend/Service Zend/Session -Zend/Soap Zend/Test Zend/Translator -Zend/Validator Zend/Wildfire -Zend/XmlRpc diff --git a/.travis/tested-components b/.travis/tested-components index 34047abc..da5b101b 100644 --- a/.travis/tested-components +++ b/.travis/tested-components @@ -1,40 +1,54 @@ -Zend/Mvc -Zend/View Zend/Acl Zend/Authentication +Zend/Cache Zend/Captcha Zend/Cloud +Zend/Code Zend/Config Zend/Console Zend/Crypt Zend/Currency Zend/Db Zend/Di +Zend/Docbook Zend/Dojo Zend/Dom Zend/EventManager +Zend/File +Zend/Filter Zend/Form +Zend/GData Zend/Http Zend/InfoCard +Zend/Json Zend/Ldap Zend/Loader +Zend/Locale Zend/Log +Zend/Mail Zend/Markup Zend/Measure Zend/Memory +Zend/Mime Zend/Module Zend/Mvc +Zend/Navigation Zend/OAuth +Zend/OpenId Zend/Pdf Zend/ProgressBar +Zend/RegistryTest.php Zend/Rest Zend/Search Zend/Serializer Zend/Server +Zend/Soap Zend/Stdlib Zend/Tag Zend/Text Zend/TimeSync Zend/Uri +Zend/Validator Zend/VersionTest.php Zend/View +Zend/XmlRpc From aa8933e5a61f8bbc39ec3ea0315a10c814e3ea7d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 4 Apr 2012 22:16:58 +0200 Subject: [PATCH 093/123] Fixing exit code and output of test runner The test-runner will run all test suites and display their names anyway, then use an appropriate exit code in case of failures. Using the list of components to be tested (was using the skipped components list to be sure that the exit code of the test runner were correct). --- .travis/run-tests.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh index 47d0c4a0..11d98cd6 100755 --- a/.travis/run-tests.sh +++ b/.travis/run-tests.sh @@ -2,7 +2,13 @@ travisdir=$(dirname $(readlink /proc/$$/fd/255)) testdir="$travisdir/../tests" testedcomponents=(`cat "$travisdir/tested-components"`) +result=0 for tested in "${testedcomponents[@]}" - do phpunit -c $testdir/phpunit.xml $testdir/$tested + do + echo "$tested:" + phpunit -c $testdir/phpunit.xml $testdir/$tested + let "result = $result || $?" done + +exit $result \ No newline at end of file From 456d33156d551789f5f5a97a3fb232854a33fe6a Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 9 Apr 2012 11:28:58 -0500 Subject: [PATCH 094/123] [zendframework/zf2#1008] Updated test lists - Moved Session, Paginator to tested-components - Added Zend/Feed/Reader, Writer to tested-components --- .travis/skipped-components | 2 -- .travis/tested-components | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis/skipped-components b/.travis/skipped-components index 6ccd1be1..6847359d 100644 --- a/.travis/skipped-components +++ b/.travis/skipped-components @@ -2,10 +2,8 @@ Zend/Amf Zend/Barcode Zend/Date Zend/Feed -Zend/Paginator Zend/Queue Zend/Service -Zend/Session Zend/Test Zend/Translator Zend/Wildfire diff --git a/.travis/tested-components b/.travis/tested-components index da5b101b..330e5f19 100644 --- a/.travis/tested-components +++ b/.travis/tested-components @@ -14,6 +14,8 @@ Zend/Docbook Zend/Dojo Zend/Dom Zend/EventManager +Zend/Feed/Reader +Zend/Feed/Writer Zend/File Zend/Filter Zend/Form @@ -35,6 +37,7 @@ Zend/Mvc Zend/Navigation Zend/OAuth Zend/OpenId +Zend/Paginator Zend/Pdf Zend/ProgressBar Zend/RegistryTest.php @@ -42,6 +45,7 @@ Zend/Rest Zend/Search Zend/Serializer Zend/Server +Zend/Session Zend/Soap Zend/Stdlib Zend/Tag From 759fbf1c42e98533559e97712adb4c47116d7ecd Mon Sep 17 00:00:00 2001 From: prolic Date: Sun, 22 Apr 2012 21:12:23 +0200 Subject: [PATCH 095/123] [zen-27] Renamed interfaces in Zend\Soap --- src/Server.php | 50 ++++++++++--------- .../ArrayOfTypeComplex.php | 4 +- src/Wsdl/ComplexTypeStrategy/Composite.php | 16 +++--- .../DefaultComplexType.php | 3 +- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/Server.php b/src/Server.php index 76fff2c0..200c4c3e 100644 --- a/src/Server.php +++ b/src/Server.php @@ -21,7 +21,11 @@ namespace Zend\Soap; -use Zend\Config\Config; +use Zend\Config\Config, + DOMDocument, + DOMNode, + SimpleXMLElement, + stdClass; /** * Zend_Soap_Server @@ -265,8 +269,8 @@ public function getOptions() * Set encoding * * @param string $encoding - * @return \Zend\Soap\Server - * @throws \Exception\InvalidArgumentException with invalid encoding argument + * @return Server + * @throws Exception\InvalidArgumentException with invalid encoding argument */ public function setEncoding($encoding) { @@ -292,7 +296,7 @@ public function getEncoding() * Set SOAP version * * @param int $version One of the SOAP_1_1 or SOAP_1_2 constants - * @return \Zend\Soap\Server + * @return Server * @throws Exception\InvalidArgumentException with invalid soap version argument */ public function setSoapVersion($version) @@ -338,7 +342,7 @@ public function validateUrn($urn) * Actor is the actor URI for the server. * * @param string $actor - * @return \Zend\Soap\Server + * @return Server */ public function setActor($actor) { @@ -363,7 +367,7 @@ public function getActor() * URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'. * * @param string $uri - * @return \Zend\Soap\Server + * @return Server */ public function setUri($uri) { @@ -386,7 +390,7 @@ public function getUri() * Set classmap * * @param array $classmap - * @return \Zend\Soap\Server + * @return Server * @throws Exception\InvalidArgumentException for any invalid class in the class map */ public function setClassmap($classmap) @@ -418,7 +422,7 @@ public function getClassmap() * Set wsdl * * @param string $wsdl URI or path to a WSDL - * @return \Zend\Soap\Server + * @return Server */ public function setWSDL($wsdl) { @@ -440,7 +444,7 @@ public function getWSDL() * Set the SOAP Feature options. * * @param string|int $feature - * @return \Zend\Soap\Server + * @return Server */ public function setSoapFeatures($feature) { @@ -462,7 +466,7 @@ public function getSoapFeatures() * Set the SOAP WSDL Caching Options * * @param string|int|boolean $caching - * @return \Zend\Soap\Server + * @return Server */ public function setWSDLCache($options) { @@ -484,7 +488,7 @@ public function getWSDLCache() * @param array|string $function Function name, array of function names to attach, * or SOAP_FUNCTIONS_ALL to attach all functions * @param string $namespace Ignored - * @return \Zend\Soap\Server + * @return Server * @throws Exception\InvalidArgumentException on invalid functions */ public function addFunction($function, $namespace = '') @@ -527,7 +531,7 @@ public function addFunction($function, $namespace = '') * See {@link setObject()} to set preconfigured object instances as request handlers. * * @param string|object $class Class name or object instance which executes SOAP Requests at endpoint. - * @return \Zend\Soap\Server + * @return Server * @throws Exception\InvalidArgumentException if called more than once, or if class * does not exist */ @@ -564,7 +568,7 @@ public function setClass($class, $namespace = '', $argv = null) * Accepts an instanciated object to use when handling requests. * * @param object $object - * @return \Zend\Soap\Server + * @return Server */ public function setObject($object) { @@ -619,7 +623,7 @@ public function loadFunctions($definition) * Set server persistence * * @param int $mode - * @return \Zend\Soap\Server + * @return Server */ public function setPersistence($mode) { @@ -634,7 +638,7 @@ public function setPersistence($mode) /** * Get server persistence * - * @return \Zend\Soap\Server + * @return Server */ public function getPersistence() { @@ -652,15 +656,15 @@ public function getPersistence() * - string; if so, verifies XML * * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request - * @return \Zend\Soap\Server + * @return Server */ protected function _setRequest($request) { - if ($request instanceof \DOMDocument) { + if ($request instanceof DOMDocument) { $xml = $request->saveXML(); - } elseif ($request instanceof \DOMNode) { + } elseif ($request instanceof DOMNode) { $xml = $request->ownerDocument->saveXML(); - } elseif ($request instanceof \SimpleXMLElement) { + } elseif ($request instanceof SimpleXMLElement) { $xml = $request->asXML(); } elseif (is_object($request) || is_string($request)) { if (is_object($request)) { @@ -669,7 +673,7 @@ protected function _setRequest($request) $xml = $request; } - $dom = new \DOMDocument(); + $dom = new DOMDocument(); if(strlen($xml) == 0 || !$dom->loadXML($xml)) { throw new Exception\InvalidArgumentException('Invalid XML'); } @@ -697,7 +701,7 @@ public function getLastRequest() * The response is always available via {@link getResponse()}. * * @param boolean $flag - * @return \Zend\Soap\Server + * @return Server */ public function setReturnResponse($flag = true) { @@ -785,7 +789,7 @@ public function handle($request = null) $request = file_get_contents('php://input'); } - // Set \Zend\Soap\Server error handler + // Set Server error handler $displayErrorsOriginalState = $this->_initializeSoapErrorContext(); $setRequestException = null; @@ -840,7 +844,7 @@ protected function _initializeSoapErrorContext() * Register a valid fault exception * * @param string|array $class Exception class or array of exception classes - * @return \Zend\Soap\Server + * @return Server */ public function registerFaultException($class) { diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php index 4831abc9..f96210c2 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php @@ -21,9 +21,7 @@ namespace Zend\Soap\Wsdl\ComplexTypeStrategy; -use Zend\Soap, - Zend\Soap\Wsdl, - Zend\Soap\Exception; +use Zend\Soap\Exception; /** * ArrayOfTypeComplex strategy diff --git a/src/Wsdl/ComplexTypeStrategy/Composite.php b/src/Wsdl/ComplexTypeStrategy/Composite.php index 89569199..be496b0e 100644 --- a/src/Wsdl/ComplexTypeStrategy/Composite.php +++ b/src/Wsdl/ComplexTypeStrategy/Composite.php @@ -34,7 +34,7 @@ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Composite implements ComplexTypeStrategyInterface +class Composite implements ComplexTypeStrategy { /** * Typemap of Complex Type => Strategy pairs. @@ -46,7 +46,7 @@ class Composite implements ComplexTypeStrategyInterface /** * Default Strategy of this composite * - * @var string|\Zend\Soap\Wsdl\Strategy + * @var string|ComplexTypeStrategy */ protected $_defaultStrategy; @@ -61,9 +61,9 @@ class Composite implements ComplexTypeStrategyInterface * Construct Composite WSDL Strategy. * * @param array $typeMap - * @param string|\Zend\Soap\Wsdl\Strategy $defaultStrategy + * @param string|ComplexTypeStrategy $defaultStrategy */ - public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap\Wsdl\Strategy\DefaultComplexType') + public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType') { foreach($typeMap AS $type => $strategy) { $this->connectTypeToStrategy($type, $strategy); @@ -76,8 +76,8 @@ public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap * * @throws Exception\InvalidArgumentException * @param string $type - * @param string|\Zend\Soap\Wsdl\Strategy $strategy - * @return omposite + * @param string|ComplexTypeStrategy $strategy + * @return Composite */ public function connectTypeToStrategy($type, $strategy) { @@ -93,7 +93,7 @@ public function connectTypeToStrategy($type, $strategy) * * @throws Exception\InvalidArgumentException * @param string $type - * @return \Zend\Soap\Wsdl\Strategy + * @return ComplexTypeStrategy */ public function getDefaultStrategy() { @@ -115,7 +115,7 @@ public function getDefaultStrategy() * * @throws Exception\InvalidArgumentException * @param string $type - * @return \Zend\Soap\Wsdl\Strategy + * @return ComplexTypeStrategy */ public function getStrategyOfType($type) { diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index b2349063..767ea483 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -21,8 +21,7 @@ namespace Zend\Soap\Wsdl\ComplexTypeStrategy; -use Zend\Soap, - Zend\Soap\Exception; +use Zend\Soap\Exception; /** * Zend_Soap_Wsdl_Strategy_DefaultComplexType From 4de219f97d2706572884c71a568524908d88bc1f Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 9 May 2012 11:28:05 -0500 Subject: [PATCH 096/123] Remove --stderr switch from Travis test runner - Appears that it may not be necessary --- .travis/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh index 1ba31be7..9334e959 100755 --- a/.travis/run-tests.sh +++ b/.travis/run-tests.sh @@ -7,7 +7,7 @@ result=0 for tested in "${testedcomponents[@]}" do echo "$tested:" - phpunit -c $testdir/phpunit.xml --stderr $testdir/$tested + phpunit -c $testdir/phpunit.xml $testdir/$tested result=$(($result || $?)) done From e94a576862695372e5fc98d2b8e3c98e942f5168 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 11 May 2012 00:35:19 +0200 Subject: [PATCH 097/123] [Config] Remove uses of Zend\Config\Config in favor of Traversable --- src/Client.php | 16 +++++++++------- src/Server.php | 11 ++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Client.php b/src/Client.php index b0de2cd2..f2cc96be 100644 --- a/src/Client.php +++ b/src/Client.php @@ -21,6 +21,8 @@ namespace Zend\Soap; +use Traversable; +use Zend\Stdlib\ArrayUtils; use Zend\Server\Client as ServerClient; /** @@ -130,9 +132,9 @@ class Client implements ServerClient /** * Constructor * - * @param string $wsdl - * @param array $options - * @throws \Zend\Soap\Client\Exception + * @param string $wsdl + * @param array|Traversable $options + * @throws Exception\ExtensionNotLoadedException */ public function __construct($wsdl = null, $options = null) { @@ -177,14 +179,14 @@ public function getWSDL() * * Allows setting options as an associative array of option => value pairs. * - * @param array|\Zend\Config\Config $options + * @param array|Traversable $options * @return \Zend\Soap\Client\Client - * @throws \Zend\Soap\Client\Exception + * @throws Exception\InvalidArgumentException */ public function setOptions($options) { - if($options instanceof \Zend\Config\Config) { - $options = $options->toArray(); + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); } foreach ($options as $key => $value) { diff --git a/src/Server.php b/src/Server.php index 200c4c3e..46b54668 100644 --- a/src/Server.php +++ b/src/Server.php @@ -21,8 +21,9 @@ namespace Zend\Soap; -use Zend\Config\Config, - DOMDocument, +use Traversable; +use Zend\Stdlib\ArrayUtils; +use DOMDocument, DOMNode, SimpleXMLElement, stdClass; @@ -179,13 +180,13 @@ public function __construct($wsdl = null, array $options = null) * * Allows setting options as an associative array of option => value pairs. * - * @param array|\Zend\Config\Config $options + * @param array|Traversable $options * @return \Zend\Soap\Server */ public function setOptions($options) { - if($options instanceof Config) { - $options = $options->toArray(); + if ($options instanceof Traversable) { + $options = ArrayUtils::iteratorToArray($options); } foreach ($options as $key => $value) { From 6970e3e82fa17b6563d64f7a8ec84d28e3b0349d Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 11 May 2012 11:06:08 +0200 Subject: [PATCH 098/123] [Tests] Update Travis script --- .travis/run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/run-tests.sh b/.travis/run-tests.sh index 9334e959..7e1baa3b 100755 --- a/.travis/run-tests.sh +++ b/.travis/run-tests.sh @@ -7,7 +7,7 @@ result=0 for tested in "${testedcomponents[@]}" do echo "$tested:" - phpunit -c $testdir/phpunit.xml $testdir/$tested + phpunit -c $testdir/phpunit.xml.dist $testdir/$tested result=$(($result || $?)) done From ad3cef5716841677fc18686852a072df81cf587e Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 11 May 2012 11:41:23 -0500 Subject: [PATCH 099/123] [zen-27][zendframework/zf2#1198] travis update - Remove Zend\Feed from skipped components list --- .travis/skipped-components | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis/skipped-components b/.travis/skipped-components index 6847359d..0790ed22 100644 --- a/.travis/skipped-components +++ b/.travis/skipped-components @@ -1,7 +1,6 @@ Zend/Amf Zend/Barcode Zend/Date -Zend/Feed Zend/Queue Zend/Service Zend/Test From 168ef7fc57ecc186c947666c34e838b6c4361ea9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 11 May 2012 11:57:50 -0500 Subject: [PATCH 100/123] [zendframework/zf2#1199] Allow testing barcode - also changed tested-components to merely list "Zend\Feed", so all of feed is executed --- .travis/skipped-components | 1 - .travis/tested-components | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis/skipped-components b/.travis/skipped-components index 0790ed22..c4cd7065 100644 --- a/.travis/skipped-components +++ b/.travis/skipped-components @@ -1,5 +1,4 @@ Zend/Amf -Zend/Barcode Zend/Date Zend/Queue Zend/Service diff --git a/.travis/tested-components b/.travis/tested-components index c0fe6477..d1d71333 100644 --- a/.travis/tested-components +++ b/.travis/tested-components @@ -1,5 +1,6 @@ Zend/Acl Zend/Authentication +Zend/Barcode Zend/Cache Zend/Captcha Zend/Cloud @@ -14,8 +15,7 @@ Zend/DocBook Zend/Dojo Zend/Dom Zend/EventManager -Zend/Feed/Reader -Zend/Feed/Writer +Zend/Feed Zend/File Zend/Filter Zend/Form From fbd7f2ab1902afbb421f4fd88aefcee6868764ef Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 11 May 2012 12:18:48 -0500 Subject: [PATCH 101/123] [zen-27][zendframework/zf2#1199] Fix Translator tests - Fixes log setup and usage in tests and code for Translator - Re-enabled Translator tests, as they now appear to work --- .travis/skipped-components | 1 - .travis/tested-components | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/skipped-components b/.travis/skipped-components index c4cd7065..31bcaa87 100644 --- a/.travis/skipped-components +++ b/.travis/skipped-components @@ -3,5 +3,4 @@ Zend/Date Zend/Queue Zend/Service Zend/Test -Zend/Translator Zend/Wildfire diff --git a/.travis/tested-components b/.travis/tested-components index d1d71333..b1f4a794 100644 --- a/.travis/tested-components +++ b/.travis/tested-components @@ -51,6 +51,7 @@ Zend/Stdlib Zend/Tag Zend/Text Zend/TimeSync +Zend/Translator Zend/Uri Zend/Validator Zend/VersionTest.php From 8c188a5b0cf9ca37746d3f9daa3ec7be486c0f9f Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 11 May 2012 08:17:31 -0500 Subject: [PATCH 102/123] [zen-12] Removed Dojo from test suite - Dojo integration largely relied on integration with Zend\Form; removing from testing for now, as it has not been refactored to work with the new Zend\Form code. --- .travis/skipped-components | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis/skipped-components b/.travis/skipped-components index 31bcaa87..171dfe9d 100644 --- a/.travis/skipped-components +++ b/.travis/skipped-components @@ -1,5 +1,6 @@ Zend/Amf Zend/Date +Zend/Dojo Zend/Queue Zend/Service Zend/Test From 146e00ae91661303c09631c727c8d6e3934cb930 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Fri, 18 May 2012 00:22:37 +0200 Subject: [PATCH 103/123] [Travis] Enable Zend\Math tests --- .travis/tested-components | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis/tested-components b/.travis/tested-components index b1f4a794..9b338206 100644 --- a/.travis/tested-components +++ b/.travis/tested-components @@ -29,6 +29,7 @@ Zend/Locale Zend/Log Zend/Mail Zend/Markup +Zend/Math Zend/Measure Zend/Memory Zend/Mime From 66db43af15d1d71daf191a265ddeb80cfe22003b Mon Sep 17 00:00:00 2001 From: Maks3w Date: Mon, 9 Jul 2012 16:19:42 +0200 Subject: [PATCH 104/123] [CS][Library] Set File Header http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards#CodingStandards-Files The following script replaces the content between PHP open tag and namespace declaration. for COMPONENT in $(ls -d *) do for FILE in $(find $COMPONENT -name "*.php") do BLOCK="\/\*\*\n \* Zend Framework \(http:\/\/framework\.zend\.com\/\)\n \*\n \* \@link http:\/\/github\.com\/zendframework\/zf2 for the canonical source repository\n \* \@copyright Copyright \(c\) 2005-2012 Zend Technologies USA Inc\. \(http:\/\/www\.zend\.com\)\n \* \@license http:\/\/framework\.zend\.com\/license\/new-bsd New BSD License\n \* \@package Zend_$COMPONENT\n \*\/" perl -0777 -i -pe "s/(<\?php(\s*.*)*\nn)/ Date: Mon, 9 Jul 2012 16:34:21 +0200 Subject: [PATCH 105/123] [CS][test] Remove @copyright & @license for fl in $(find . -name "*.php"); do mv $fl $fl.old; sed '/@copyright/d' $fl.old > $fl; rm -f $fl.old; done; for fl in $(find . -name "*.php"); do mv $fl $fl.old; sed '/@license/d' $fl.old > $fl; rm -f $fl.old; done; --- test/AutoDiscover/OnlineTest.php | 4 --- test/AutoDiscoverTest.php | 4 --- test/ClientTest.php | 4 --- test/Server/DocumentLiteralWrapperTest.php | 2 -- test/ServerTest.php | 4 --- test/TestAsset/MyCalculatorService.php | 2 -- test/TestAsset/commontypes.php | 28 ------------------- test/TestAsset/fulltests/server1.php | 8 ------ test/TestAsset/fulltests/server2.php | 6 ---- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 4 --- test/Wsdl/ArrayOfTypeSequenceStrategyTest.php | 4 --- test/Wsdl/CompositeStrategyTest.php | 4 --- test/Wsdl/DefaultComplexTypeTest.php | 4 --- test/WsdlTest.php | 4 --- test/_files/commontypes.php | 28 ------------------- test/_files/fulltests/server1.php | 8 ------ test/_files/fulltests/server2.php | 6 ---- 17 files changed, 124 deletions(-) diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index d347d4d9..5a0b24cf 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\AutoDiscover; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ class OnlineTest extends \PHPUnit_Framework_TestCase diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 2b0ab878..b39c4269 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap; @@ -35,8 +33,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ class AutoDiscoverTest extends \PHPUnit_Framework_TestCase diff --git a/test/ClientTest.php b/test/ClientTest.php index f59bab55..32d2b05c 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap */ class ClientTest extends \PHPUnit_Framework_TestCase diff --git a/test/Server/DocumentLiteralWrapperTest.php b/test/Server/DocumentLiteralWrapperTest.php index ae9c4e08..f40ca9a6 100644 --- a/test/Server/DocumentLiteralWrapperTest.php +++ b/test/Server/DocumentLiteralWrapperTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\Server; diff --git a/test/ServerTest.php b/test/ServerTest.php index ff76530a..57d10b56 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Server */ diff --git a/test/TestAsset/MyCalculatorService.php b/test/TestAsset/MyCalculatorService.php index 853b0109..26b70139 100644 --- a/test/TestAsset/MyCalculatorService.php +++ b/test/TestAsset/MyCalculatorService.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\TestAsset; diff --git a/test/TestAsset/commontypes.php b/test/TestAsset/commontypes.php index 334c5a8b..e6bb6349 100644 --- a/test/TestAsset/commontypes.php +++ b/test/TestAsset/commontypes.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\TestAsset; @@ -119,8 +117,6 @@ function TestFunc9($foo, $bar) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class TestFixingMultiplePrototypes { @@ -142,8 +138,6 @@ function testFunc($a=100, $b=200, $d=300) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Test { /** @@ -207,8 +201,6 @@ class AutoDiscoverTestClass1 * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class AutoDiscoverTestClass2 { @@ -246,8 +238,6 @@ public function addMultiple($test) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexTypeB { @@ -265,8 +255,6 @@ class ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexTypeA { @@ -280,8 +268,6 @@ class ComplexTypeA * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexTest { @@ -295,8 +281,6 @@ class ComplexTest * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexObjectStructure { @@ -325,8 +309,6 @@ class ComplexObjectStructure * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexObjectWithObjectStructure { @@ -340,8 +322,6 @@ class ComplexObjectWithObjectStructure * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class MyService { @@ -370,8 +350,6 @@ public function baz($baz) { * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class MyServiceSequence { @@ -407,8 +385,6 @@ public function bazNested($baz) { * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class MyResponse { @@ -422,8 +398,6 @@ class MyResponse * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Recursion { @@ -450,8 +424,6 @@ function OneWay($message) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class NoReturnType { diff --git a/test/TestAsset/fulltests/server1.php b/test/TestAsset/fulltests/server1.php index 4df21920..271e4e50 100644 --- a/test/TestAsset/fulltests/server1.php +++ b/test/TestAsset/fulltests/server1.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\TestAsset\fulltests; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Server1 { @@ -58,8 +54,6 @@ public function request($request) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexTypeB { @@ -77,8 +71,6 @@ class ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexTypeA { diff --git a/test/TestAsset/fulltests/server2.php b/test/TestAsset/fulltests/server2.php index 95ce1f32..7a1c732b 100644 --- a/test/TestAsset/fulltests/server2.php +++ b/test/TestAsset/fulltests/server2.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\TestAsset\fulltests; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ComplexTypeB { @@ -44,8 +40,6 @@ class ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Server2 { diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index 13e09826..887449fc 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\Wsdl; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl */ diff --git a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php index 17bd6e82..2798f2bf 100644 --- a/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeSequenceStrategyTest.php @@ -14,8 +14,6 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\Wsdl; @@ -26,8 +24,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl */ diff --git a/test/Wsdl/CompositeStrategyTest.php b/test/Wsdl/CompositeStrategyTest.php index 31b8a6af..628bfba9 100644 --- a/test/Wsdl/CompositeStrategyTest.php +++ b/test/Wsdl/CompositeStrategyTest.php @@ -14,8 +14,6 @@ * * @category Zend * @package Zend_Soap - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\Wsdl; @@ -39,8 +37,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl */ diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index 76dd87bd..e2ca9378 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap\Wsdl; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl */ diff --git a/test/WsdlTest.php b/test/WsdlTest.php index f17c8b1a..2926bdbf 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\Soap; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Soap * @group Zend_Soap_Wsdl */ diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index b0fe768f..9852869b 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: commontypes.php 21858 2010-04-15 19:58:12Z beberlei $ */ @@ -118,8 +116,6 @@ function Zend_Soap_AutoDiscover_TestFunc9($foo, $bar) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_TestFixingMultiplePrototypes { @@ -141,8 +137,6 @@ function testFunc($a=100, $b=200, $d=300) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_Test { /** @@ -206,8 +200,6 @@ class Zend_Soap_AutoDiscoverTestClass1 * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscoverTestClass2 { @@ -245,8 +237,6 @@ public function addMultiple($test) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeB { @@ -264,8 +254,6 @@ class Zend_Soap_Wsdl_ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeA { @@ -279,8 +267,6 @@ class Zend_Soap_Wsdl_ComplexTypeA * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTest { @@ -294,8 +280,6 @@ class Zend_Soap_Wsdl_ComplexTest * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexObjectStructure { @@ -324,8 +308,6 @@ class Zend_Soap_Wsdl_ComplexObjectStructure * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure { @@ -339,8 +321,6 @@ class Zend_Soap_Wsdl_ComplexObjectWithObjectStructure * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_MyService { @@ -369,8 +349,6 @@ public function baz($baz) { * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_MyServiceSequence { @@ -406,8 +384,6 @@ public function bazNested($baz) { * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_MyResponse { @@ -421,8 +397,6 @@ class Zend_Soap_AutoDiscover_MyResponse * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_Recursion { @@ -449,8 +423,6 @@ function Zend_Soap_AutoDiscover_OneWay($message) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_AutoDiscover_NoReturnType { diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php index a028f766..c2ab7a85 100644 --- a/test/_files/fulltests/server1.php +++ b/test/_files/fulltests/server1.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: server1.php 20096 2010-01-06 02:05:09Z bkarwin $ */ @@ -28,8 +26,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Service_Server1 { @@ -61,8 +57,6 @@ public function request($request) * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeB { @@ -80,8 +74,6 @@ class Zend_Soap_Wsdl_ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeA { diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index 28f32204..062c63fb 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: server2.php 20096 2010-01-06 02:05:09Z bkarwin $ */ @@ -28,8 +26,6 @@ * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Wsdl_ComplexTypeB { @@ -47,8 +43,6 @@ class Zend_Soap_Wsdl_ComplexTypeB * @category Zend * @package Zend_Soap * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Soap_Service_Server2 { From 7ecccf412205434665b59a2048279c68ed8fcc55 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Mon, 9 Jul 2012 16:41:27 +0200 Subject: [PATCH 106/123] [CS][Tests] Set File Header http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards#CodingStandards-Files The following script replaces the content between PHP open tag and namespace declaration. for COMPONENT in $(ls -d *) do for FILE in $(find $COMPONENT -name "*.php") do BLOCK="\/\*\*\n \* Zend Framework \(http:\/\/framework\.zend\.com\/\)\n \*\n \* \@link http:\/\/github\.com\/zendframework\/zf2 for the canonical source repository\n \* \@copyright Copyright \(c\) 2005-2012 Zend Technologies USA Inc\. \(http:\/\/www\.zend\.com\)\n \* \@license http:\/\/framework\.zend\.com\/license\/new-bsd New BSD License\n \* \@package Zend_$COMPONENT\n \*\/" perl -0777 -i -pe "s/(<\?php(\s*.*)*\nn)/ Date: Mon, 9 Jul 2012 16:47:31 +0200 Subject: [PATCH 107/123] [CS][Tests] Set File Header http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards#CodingStandards-Files The following script replaces the content of the first comment in the file (useful for files without namespace declaration) for COMPONENT in $(ls -d *) do for FILE in $(find $COMPONENT -name "*.php") do BLOCK="\/\*\*\n \* Zend Framework \(http:\/\/framework\.zend\.com\/\)\n \*\n \* \@link http:\/\/github\.com\/zendframework\/zf2 for the canonical source repository\n \* \@copyright Copyright \(c\) 2005-2012 Zend Technologies USA Inc\. \(http:\/\/www\.zend\.com\)\n \* \@license http:\/\/framework\.zend\.com\/license\/new-bsd New BSD License\n \* \@package Zend_$COMPONENT\n \*\/" perl -0777 -i -pe "s/(\/\*\*(\s*\*.*)*\/)/$BLOCK/" $FILE done done --- test/_files/commontypes.php | 20 +++++--------------- test/_files/fulltests/server1.php | 20 +++++--------------- test/_files/fulltests/server2.php | 20 +++++--------------- 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index 9852869b..d221e4fa 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -1,21 +1,11 @@ Date: Mon, 9 Jul 2012 16:46:59 -0500 Subject: [PATCH 108/123] [zen-49] Correct import statements across framework - Ran a script that would create multiple import statements out of multi-line import statements, and which would sort all import statements in alphabetic order. Script is at https://gist.github.com/3079222 and was run by dropping into the library/Zend folder and typing (in zsh) "for file in **/*.php;do php /path/to/replace-uses.php $file; done" --- src/AutoDiscover.php | 18 +++++++++--------- .../DiscoveryStrategyInterface.php | 6 +++--- .../DiscoveryStrategy/ReflectionDiscovery.php | 6 +++--- src/Client.php | 2 +- src/Client/DotNet.php | 4 ++-- src/Client/Local.php | 4 ++-- src/Server.php | 8 ++++---- src/Server/DocumentLiteralWrapper.php | 8 ++++---- src/Wsdl.php | 8 ++++---- src/Wsdl/ComplexTypeStrategy/Composite.php | 6 +++--- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 84ff38e8..230d74e1 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -10,15 +10,15 @@ namespace Zend\Soap; -use Zend\Uri, - Zend\Soap\Wsdl, - Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy, - Zend\Server\Reflection\AbstractFunction, - Zend\Server\Reflection, - Zend\Server\Reflection\Prototype, - Zend\Server\Reflection\ReflectionParameter, - Zend\Soap\AutoDiscover\DiscoveryStrategy\ReflectionDiscovery, - Zend\Soap\AutoDiscover\DiscoveryStrategy\DiscoveryStrategyInterface as DiscoveryStrategy; +use Zend\Server\Reflection; +use Zend\Server\Reflection\AbstractFunction; +use Zend\Server\Reflection\Prototype; +use Zend\Server\Reflection\ReflectionParameter; +use Zend\Soap\AutoDiscover\DiscoveryStrategy\DiscoveryStrategyInterface as DiscoveryStrategy; +use Zend\Soap\AutoDiscover\DiscoveryStrategy\ReflectionDiscovery; +use Zend\Soap\Wsdl; +use Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy; +use Zend\Uri; /** * \Zend\Soap\AutoDiscover diff --git a/src/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php b/src/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php index 9c5e84c5..e02ff7f8 100644 --- a/src/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php +++ b/src/AutoDiscover/DiscoveryStrategy/DiscoveryStrategyInterface.php @@ -10,9 +10,9 @@ namespace Zend\Soap\AutoDiscover\DiscoveryStrategy; -use Zend\Server\Reflection\AbstractFunction, - Zend\Server\Reflection\Prototype, - Zend\Server\Reflection\ReflectionParameter; +use Zend\Server\Reflection\AbstractFunction; +use Zend\Server\Reflection\Prototype; +use Zend\Server\Reflection\ReflectionParameter; /** * Describes how types, return values and method details are detected during AutoDiscovery of a WSDL. diff --git a/src/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php b/src/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php index ff97f74c..bc025d2b 100644 --- a/src/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php +++ b/src/AutoDiscover/DiscoveryStrategy/ReflectionDiscovery.php @@ -10,9 +10,9 @@ namespace Zend\Soap\AutoDiscover\DiscoveryStrategy; -use Zend\Server\Reflection\AbstractFunction, - Zend\Server\Reflection\Prototype, - Zend\Server\Reflection\ReflectionParameter; +use Zend\Server\Reflection\AbstractFunction; +use Zend\Server\Reflection\Prototype; +use Zend\Server\Reflection\ReflectionParameter; /** * Describes how types, return values and method details are detected during AutoDiscovery of a WSDL. diff --git a/src/Client.php b/src/Client.php index a912a07b..47856030 100644 --- a/src/Client.php +++ b/src/Client.php @@ -11,8 +11,8 @@ namespace Zend\Soap; use Traversable; -use Zend\Stdlib\ArrayUtils; use Zend\Server\Client as ServerClient; +use Zend\Stdlib\ArrayUtils; /** * \Zend\Soap\Client\Client diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index 1bb485be..855ab102 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -10,8 +10,8 @@ namespace Zend\Soap\Client; -use Zend\Soap\Client as SOAPClient, - Zend\Soap\Exception; +use Zend\Soap\Client as SOAPClient; +use Zend\Soap\Exception; /** * .NET SOAP client diff --git a/src/Client/Local.php b/src/Client/Local.php index e481f51c..6d90484f 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -10,8 +10,8 @@ namespace Zend\Soap\Client; -use Zend\Soap\Client as SOAPClient, - Zend\Soap\Server as SOAPServer; +use Zend\Soap\Client as SOAPClient; +use Zend\Soap\Server as SOAPServer; /** * \Zend\Soap\Client\Local diff --git a/src/Server.php b/src/Server.php index 56b44e52..2103efce 100644 --- a/src/Server.php +++ b/src/Server.php @@ -10,12 +10,12 @@ namespace Zend\Soap; +use DOMDocument; +use DOMNode; +use SimpleXMLElement; +use stdClass; use Traversable; use Zend\Stdlib\ArrayUtils; -use DOMDocument, - DOMNode, - SimpleXMLElement, - stdClass; /** * Zend_Soap_Server diff --git a/src/Server/DocumentLiteralWrapper.php b/src/Server/DocumentLiteralWrapper.php index 7017b509..646f7bc9 100644 --- a/src/Server/DocumentLiteralWrapper.php +++ b/src/Server/DocumentLiteralWrapper.php @@ -10,10 +10,10 @@ namespace Zend\Soap\Server; -use ReflectionClass, - ReflectionObject, - Zend\Soap\Exception\UnexpectedValueException, - Zend\Soap\Exception\BadMethodCallException; +use ReflectionClass; +use ReflectionObject; +use Zend\Soap\Exception\BadMethodCallException; +use Zend\Soap\Exception\UnexpectedValueException; /** * Wraps WSDL Document/Literal Style service objects to hide SOAP request diff --git a/src/Wsdl.php b/src/Wsdl.php index ea4b790a..f604cf2c 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -10,10 +10,10 @@ namespace Zend\Soap; -use DOMDocument, - DOMElement, - Zend\Uri\Uri, - Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy; +use DOMDocument; +use DOMElement; +use Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy; +use Zend\Uri\Uri; /** * \Zend\Soap\Wsdl diff --git a/src/Wsdl/ComplexTypeStrategy/Composite.php b/src/Wsdl/ComplexTypeStrategy/Composite.php index 9a70225f..9cd20820 100644 --- a/src/Wsdl/ComplexTypeStrategy/Composite.php +++ b/src/Wsdl/ComplexTypeStrategy/Composite.php @@ -10,9 +10,9 @@ namespace Zend\Soap\Wsdl\ComplexTypeStrategy; -use Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy, - Zend\Soap\Exception, - Zend\Soap\Wsdl; +use Zend\Soap\Exception; +use Zend\Soap\Wsdl; +use Zend\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy; /** * Zend_Soap_Wsdl_Strategy_Composite From d99480318326438345dc92121ace6a3e020c90b0 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 11 Jul 2012 22:11:34 +0200 Subject: [PATCH 109/123] Remove global prefix in use statements --- test/Wsdl/ArrayOfTypeComplexStrategyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php index dfb154cd..00298010 100644 --- a/test/Wsdl/ArrayOfTypeComplexStrategyTest.php +++ b/test/Wsdl/ArrayOfTypeComplexStrategyTest.php @@ -13,7 +13,7 @@ require_once __DIR__."/../TestAsset/commontypes.php"; use Zend\Soap\Wsdl; -use \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex; +use Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex; /** * @category Zend From fafc8ae83f5352c901b249b9bbd282e8d63b9da2 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 11 Jul 2012 22:20:59 +0200 Subject: [PATCH 110/123] Add blank lines around the use block --- test/AutoDiscover/OnlineTest.php | 1 + test/WsdlTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index c8922f7d..2765f936 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\Soap\AutoDiscover; + require_once __DIR__ . '/../TestAsset/commontypes.php'; use Zend\Soap\Client; diff --git a/test/WsdlTest.php b/test/WsdlTest.php index ce4a61de..cc8febef 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\Soap; + use Zend\Soap\Wsdl; use Zend\Soap\Wsdl\ComplexTypeStrategy; From 88de986b1db72b4e57974b12401f0501c94dab61 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Thu, 12 Jul 2012 21:11:36 +0200 Subject: [PATCH 111/123] [PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed --- src/AutoDiscover.php | 2 +- .../ArrayOfTypeSequence.php | 2 +- test/ServerTest.php | 36 ++++++++-------- test/TestAsset/MyCalculatorService.php | 2 +- test/TestAsset/WsdlTestClass.php | 3 +- test/TestAsset/commontypes.php | 42 ++++++++++++------- test/_files/commontypes.php | 24 +++++++---- 7 files changed, 67 insertions(+), 44 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 230d74e1..aa0faeed 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -471,7 +471,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) ); // Add the wrapper element part, which must be named 'parameters' $args['parameters'] = array('element' => $wsdl->addElement($element)); - } else if ($prototype->getReturnType() != "void") { + } elseif ($prototype->getReturnType() != "void") { // RPC style: add the return value as a typed part $args['return'] = array('type' => $wsdl->getType($this->_discoveryStrategy->getFunctionReturnType($function, $prototype))); } diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php index b869a23d..2e2e8084 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php @@ -43,7 +43,7 @@ public function addComplexType($type) } return $complexType; - } else if (($soapType = $this->scanRegisteredTypes($type)) !== null) { + } elseif (($soapType = $this->scanRegisteredTypes($type)) !== null) { // Existing complex type return $soapType; } else { diff --git a/test/ServerTest.php b/test/ServerTest.php index 269b6c16..5bf2cbc4 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -124,7 +124,7 @@ public function testSoapVersion() $this->assertEquals(SOAP_1_2, $server->getSoapVersion()); $server->setSoapVersion(SOAP_1_1); $this->assertEquals(SOAP_1_1, $server->getSoapVersion()); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid soap version specified'); $server->setSoapVersion('bogus'); } @@ -134,7 +134,7 @@ public function testValidateUrn() $server = new Server(); $this->assertTrue($server->validateUrn('http://framework.zend.com/')); $this->assertTrue($server->validateUrn('urn:soapHandler/GetOpt')); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid URN'); $server->validateUrn('bogosity'); } @@ -146,7 +146,7 @@ public function testSetActor() $this->assertNull($server->getActor()); $server->setActor('http://framework.zend.com/'); $this->assertEquals('http://framework.zend.com/', $server->getActor()); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid URN'); $server->setActor('bogus'); } @@ -167,7 +167,7 @@ public function testSetUri() $this->assertNull($server->getUri()); $server->setUri('http://framework.zend.com/'); $this->assertEquals('http://framework.zend.com/', $server->getUri()); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid URN'); $server->setUri('bogus'); } @@ -192,19 +192,19 @@ public function testSetClassmap() $server->setClassmap($classmap); $this->assertTrue($classmap == $server->getClassmap()); } - + public function testSetClassmapThrowsExceptionOnBogusStringParameter() { $server = new Server(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Classmap must be an array'); $server->setClassmap('bogus'); } - + public function testSetClassmapThrowsExceptionOnBogusArrayParameter() { $server = new Server(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid class in class map'); $server->setClassmap(array('soapTypeName', 'bogusClassName')); } @@ -228,7 +228,7 @@ public function testSetWsdl() $this->assertNull($server->getWSDL()); $server->setWSDL(__DIR__.'/_files/wsdl_example.wsdl'); $this->assertEquals(__DIR__.'/_files/wsdl_example.wsdl', $server->getWSDL()); - + //$this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'foo'); $server->setWSDL(__DIR__.'/_files/bogus.wsdl'); } @@ -264,7 +264,7 @@ public function testAddFunction() public function testAddBogusFunctionAsInteger() { $server = new Server(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid function specified'); $server->addFunction(126); } @@ -280,7 +280,7 @@ public function testAddBogusFunctionsAsString() public function testAddBogusFunctionsAsArray() { $server = new Server(); - + $functions = array('\ZendTest\Soap\TestAsset\TestFunc5', 'bogus_function', '\ZendTest\Soap\TestAsset\TestFunc6'); @@ -324,7 +324,7 @@ public function testSetClassTwiceThrowsException() { $server = new Server(); $server->setClass('\ZendTest\Soap\TestAsset\ServerTestClass'); - + $this->setExpectedException( 'Zend\Soap\Exception\InvalidArgumentException', 'A class has already been registered with this soap server instance' @@ -368,37 +368,37 @@ public function testSetObject() $r = $server->setObject(new TestAsset\ServerTestClass()); $this->assertSame($server, $r); } - + /** * @group ZF-4366 */ public function testSetObjectThrowsExceptionWithBadInput1() { $server = new Server(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid object argument (integer)'); $server->setObject(465); } - + /** * @group ZF-4366 */ public function testSetObjectThrowsExceptionWithBadInput2() { $server = new Server(); - + $this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'Invalid object argument (integer)'); $int = 1; $server->setObject($int); } - + /** * @group ZF-4366 */ public function testSetObjectThrowsExceptionWithBadInput3() { $server = new Server(); - + //$this->setExpectedException('Zend\Soap\Exception\InvalidArgumentException', 'foo'); $server->setObject(new TestAsset\ServerTestClass()); } diff --git a/test/TestAsset/MyCalculatorService.php b/test/TestAsset/MyCalculatorService.php index 574c92aa..a095be63 100644 --- a/test/TestAsset/MyCalculatorService.php +++ b/test/TestAsset/MyCalculatorService.php @@ -11,7 +11,7 @@ namespace ZendTest\Soap\TestAsset; /** - * MyCalculatorService + * MyCalculatorService * * Class used in DocumentLiteralWrapperTest */ diff --git a/test/TestAsset/WsdlTestClass.php b/test/TestAsset/WsdlTestClass.php index 0312eda0..2553a9a1 100644 --- a/test/TestAsset/WsdlTestClass.php +++ b/test/TestAsset/WsdlTestClass.php @@ -13,7 +13,8 @@ /** * Test Class */ -class WsdlTestClass { +class WsdlTestClass +{ /** * @var integer */ diff --git a/test/TestAsset/commontypes.php b/test/TestAsset/commontypes.php index 0b68a766..1edf85f1 100644 --- a/test/TestAsset/commontypes.php +++ b/test/TestAsset/commontypes.php @@ -130,7 +130,8 @@ function testFunc($a=100, $b=200, $d=300) * @package Zend_Soap * @subpackage UnitTests */ -class Test { +class Test +{ /** * Test Function 1 * @@ -320,20 +321,23 @@ class MyService * @param string $foo * @return \ZendTest\Soap\TestAsset\MyResponse[] */ - public function foo($foo) { + public function foo($foo) + { } /** * @param string $bar * @return \ZendTest\Soap\TestAsset\MyResponse[] */ - public function bar($bar) { + public function bar($bar) + { } /** * @param string $baz * @return \ZendTest\Soap\TestAsset\MyResponse[] */ - public function baz($baz) { + public function baz($baz) + { } } @@ -348,27 +352,31 @@ class MyServiceSequence * @param string $foo * @return string[] */ - public function foo($foo) { + public function foo($foo) + { } /** * @param string $bar * @return string[] */ - public function bar($bar) { + public function bar($bar) + { } /** * @param string $baz * @return string[] */ - public function baz($baz) { + public function baz($baz) + { } /** * @param string $baz * @return string[][][] */ - public function bazNested($baz) { + public function bazNested($baz) + { } } @@ -430,7 +438,8 @@ public function pushOneWay($message) /* Client test classes */ /** Test Class */ -class TestClass { +class TestClass +{ /** * Test Function 1 * @@ -476,7 +485,8 @@ static function testFunc4() } /** Test class 2 */ -class TestData1 { +class TestData1 +{ /** * Property1 * @@ -493,7 +503,8 @@ class TestData1 { } /** Test class 2 */ -class TestData2 { +class TestData2 +{ /** * Property1 * @@ -509,7 +520,8 @@ class TestData2 { public $property2; } -class MockSoapServer { +class MockSoapServer +{ public $handle = null; public function handle() { @@ -518,9 +530,11 @@ public function handle() public function __call($name, $args) {} } -class MockServer extends \Zend\Soap\Server { +class MockServer extends \Zend\Soap\Server +{ public $mockSoapServer = null; - protected function _getSoap() { + protected function _getSoap() + { $this->mockSoapServer = new MockSoapServer(); return $this->mockSoapServer; } diff --git a/test/_files/commontypes.php b/test/_files/commontypes.php index d221e4fa..5ef3c806 100644 --- a/test/_files/commontypes.php +++ b/test/_files/commontypes.php @@ -128,7 +128,8 @@ function testFunc($a=100, $b=200, $d=300) * @package Zend_Soap * @subpackage UnitTests */ -class Zend_Soap_AutoDiscover_Test { +class Zend_Soap_AutoDiscover_Test +{ /** * Test Function 1 * @@ -318,20 +319,23 @@ class Zend_Soap_AutoDiscover_MyService * @param string $foo * @return Zend_Soap_AutoDiscover_MyResponse[] */ - public function foo($foo) { + public function foo($foo) + { } /** * @param string $bar * @return Zend_Soap_AutoDiscover_MyResponse[] */ - public function bar($bar) { + public function bar($bar) + { } /** * @param string $baz * @return Zend_Soap_AutoDiscover_MyResponse[] */ - public function baz($baz) { + public function baz($baz) + { } } @@ -346,27 +350,31 @@ class Zend_Soap_AutoDiscover_MyServiceSequence * @param string $foo * @return string[] */ - public function foo($foo) { + public function foo($foo) + { } /** * @param string $bar * @return string[] */ - public function bar($bar) { + public function bar($bar) + { } /** * @param string $baz * @return string[] */ - public function baz($baz) { + public function baz($baz) + { } /** * @param string $baz * @return string[][][] */ - public function bazNested($baz) { + public function bazNested($baz) + { } } From d3d1dbffc52fad5996fb389b8acf27df25d44884 Mon Sep 17 00:00:00 2001 From: RWOverdijk Date: Thu, 9 Aug 2012 09:11:18 +0200 Subject: [PATCH 112/123] PSR-2 added space after control structure --- src/AutoDiscover.php | 18 +++++++++--------- src/Client.php | 2 +- src/Server.php | 16 ++++++++-------- src/Wsdl.php | 8 ++++---- .../ComplexTypeStrategy/ArrayOfTypeComplex.php | 4 ++-- .../ArrayOfTypeSequence.php | 6 +++--- src/Wsdl/ComplexTypeStrategy/Composite.php | 16 ++++++++-------- .../ComplexTypeStrategy/DefaultComplexType.php | 2 +- test/AutoDiscover/OnlineTest.php | 2 +- test/TestAsset/fulltests/server1.php | 2 +- test/TestAsset/fulltests/server2.php | 2 +- test/_files/fulltests/server1.php | 2 +- test/_files/fulltests/server2.php | 2 +- 13 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index f31ecc0d..c8d4f170 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -116,11 +116,11 @@ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=n $this->setComplexTypeStrategy($strategy); } - if($endpointUri !== null) { + if ($endpointUri !== null) { $this->setUri($endpointUri); } - if($wsdlClass !== null) { + if ($wsdlClass !== null) { $this->setWsdlClass($wsdlClass); } } @@ -226,7 +226,7 @@ public function setUri($uri) */ public function getUri() { - if($this->uri === null) { + if ($this->uri === null) { throw new Exception\RuntimeException("Missing uri. You have to explicitly configure the Endpoint Uri by calling AutoDiscover#setUri()."); } if (is_string($this->uri)) { @@ -277,7 +277,7 @@ public function getWsdlClass() */ public function setOperationBodyStyle(array $operationStyle=array()) { - if(!isset($operationStyle['use'])) { + if (!isset($operationStyle['use'])) { throw new Exception\InvalidArgumentException("Key 'use' is required in Operation soap:body style."); } $this->operationBodyStyle = $operationStyle; @@ -294,10 +294,10 @@ public function setOperationBodyStyle(array $operationStyle=array()) */ public function setBindingStyle(array $bindingStyle=array()) { - if(isset($bindingStyle['style'])) { + if (isset($bindingStyle['style'])) { $this->bindingStyle['style'] = $bindingStyle['style']; } - if(isset($bindingStyle['transport'])) { + if (isset($bindingStyle['transport'])) { $this->bindingStyle['transport'] = $bindingStyle['transport']; } return $this; @@ -453,7 +453,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) $isOneWayMessage = $this->discoveryStrategy->isFunctionOneWay($function, $prototype); - if($isOneWayMessage == false) { + if ($isOneWayMessage == false) { // Add the output message (return value) $args = array(); if ($this->bindingStyle['style'] == 'document') { @@ -479,7 +479,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } // Add the portType operation - if($isOneWayMessage == false) { + if ($isOneWayMessage == false) { $portOperation = $wsdl->addPortOperation($port, $functionName, 'tns:' . $functionName . 'In', 'tns:' . $functionName . 'Out'); } else { $portOperation = $wsdl->addPortOperation($port, $functionName, 'tns:' . $functionName . 'In', false); @@ -496,7 +496,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) } // Add the binding operation - if($isOneWayMessage == false) { + if ($isOneWayMessage == false) { $operation = $wsdl->addBindingOperation($binding, $functionName, $operationBodyStyle, $operationBodyStyle); } else { $operation = $wsdl->addBindingOperation($binding, $functionName, $operationBodyStyle); diff --git a/src/Client.php b/src/Client.php index ee9a993c..9c04a160 100644 --- a/src/Client.php +++ b/src/Client.php @@ -778,7 +778,7 @@ public function getProxyPassword() */ public function setStreamContext($context) { - if(!is_resource($context) || get_resource_type($context) !== "stream-context") { + if (!is_resource($context) || get_resource_type($context) !== "stream-context") { throw new Exception\InvalidArgumentException('Invalid stream context resource given.'); } diff --git a/src/Server.php b/src/Server.php index c7af8add..f37e5538 100644 --- a/src/Server.php +++ b/src/Server.php @@ -242,11 +242,11 @@ public function getOptions() $options['uri'] = $this->uri; } - if(null !== $this->features) { + if (null !== $this->features) { $options['features'] = $this->features; } - if(null !== $this->wsdlCache) { + if (null !== $this->wsdlCache) { $options['cache_wsdl'] = $this->wsdlCache; } @@ -560,11 +560,11 @@ public function setClass($class, $namespace = '', $argv = null) */ public function setObject($object) { - if(!is_object($object)) { + if (!is_object($object)) { throw new Exception\InvalidArgumentException('Invalid object argument ('.gettype($object).')'); } - if(isset($this->object)) { + if (isset($this->object)) { throw new Exception\InvalidArgumentException('An object has already been registered with this soap server instance'); } @@ -662,7 +662,7 @@ protected function _setRequest($request) } libxml_disable_entity_loader(true); $dom = new DOMDocument(); - if(strlen($xml) == 0 || !$dom->loadXML($xml)) { + if (strlen($xml) == 0 || !$dom->loadXML($xml)) { throw new Exception\InvalidArgumentException('Invalid XML'); } libxml_disable_entity_loader(false); @@ -791,7 +791,7 @@ public function handle($request = null) $soap = $this->_getSoap(); ob_start(); - if($setRequestException instanceof \Exception) { + if ($setRequestException instanceof \Exception) { // Send SOAP fault message if we've catched exception $soap->fault('Sender', $setRequestException->getMessage()); } else { @@ -893,7 +893,7 @@ public function fault($fault = null, $code = "Receiver") } else { $message = 'Unknown error'; } - } elseif(is_string($fault)) { + } elseif (is_string($fault)) { $message = $fault; } else { $message = 'Unknown error'; @@ -903,7 +903,7 @@ public function fault($fault = null, $code = "Receiver") 'VersionMismatch', 'MustUnderstand', 'DataEncodingUnknown', 'Sender', 'Receiver', 'Server' ); - if(!in_array($code, $allowedFaultModes)) { + if (!in_array($code, $allowedFaultModes)) { $code = "Receiver"; } diff --git a/src/Wsdl.php b/src/Wsdl.php index b0127e22..8de6b1a3 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -132,7 +132,7 @@ public function setUri($uri) $oldUri = $this->uri; $this->uri = $uri; - if($this->dom !== null) { + if ($this->dom !== null) { // @todo: This is the worst hack ever, but its needed due to design and non BC issues of WSDL generation $xml = $this->dom->saveXML(); $xml = str_replace($oldUri, $uri, $xml); @@ -418,7 +418,7 @@ public function addDocumentation($input_node, $documentation) $doc_cdata = $this->dom->createTextNode(str_replace(array("\r\n", "\r"), "\n", $documentation)); $doc->appendChild($doc_cdata); - if($node->hasChildNodes()) { + if ($node->hasChildNodes()) { $node->insertBefore($doc, $node->firstChild); } else { $node->appendChild($doc); @@ -452,7 +452,7 @@ public function addTypes($types) */ public function addType($type, $wsdlType) { - if(!isset($this->includedTypes[$type])) { + if (!isset($this->includedTypes[$type])) { $this->includedTypes[$type] = $wsdlType; } return $this; @@ -475,7 +475,7 @@ public function getTypes() */ public function getSchema() { - if($this->schema == null) { + if ($this->schema == null) { $this->addSchemaTypeSection(); } diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php index 8e0ddec8..656f0f22 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php @@ -36,9 +36,9 @@ public function addComplexType($type) $singularType = $this->_getSingularPhpType($type); $nestingLevel = $this->_getNestedCount($type); - if($nestingLevel == 0) { + if ($nestingLevel == 0) { return parent::addComplexType($singularType); - } else if($nestingLevel == 1) { + } else if ($nestingLevel == 1) { // The following blocks define the Array of Object structure return $this->_addArrayOfComplexType($singularType, $type); } else { diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php index 0ad3efc8..e95d76b6 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.php @@ -31,10 +31,10 @@ public function addComplexType($type) { $nestedCounter = $this->_getNestedCount($type); - if($nestedCounter > 0) { + if ($nestedCounter > 0) { $singularType = $this->_getSingularType($type); - for($i = 1; $i <= $nestedCounter; $i++) { + for ($i = 1; $i <= $nestedCounter; $i++) { $complexType = $this->_getTypeBasedOnNestingLevel($singularType, $i); $complexTypePhp = $singularType . str_repeat('[]', $i); $childType = $this->_getTypeBasedOnNestingLevel($singularType, $i-1); @@ -61,7 +61,7 @@ public function addComplexType($type) */ protected function _getTypeBasedOnNestingLevel($singularType, $level) { - if($level == 0) { + if ($level == 0) { // This is not an Array anymore, return the xsd simple type return $this->getContext()->getType($singularType); } else { diff --git a/src/Wsdl/ComplexTypeStrategy/Composite.php b/src/Wsdl/ComplexTypeStrategy/Composite.php index 9fd9ceb3..65b3496a 100644 --- a/src/Wsdl/ComplexTypeStrategy/Composite.php +++ b/src/Wsdl/ComplexTypeStrategy/Composite.php @@ -52,7 +52,7 @@ class Composite implements ComplexTypeStrategy */ public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType') { - foreach($typeMap AS $type => $strategy) { + foreach ($typeMap AS $type => $strategy) { $this->connectTypeToStrategy($type, $strategy); } $this->defaultStrategy = $defaultStrategy; @@ -68,7 +68,7 @@ public function __construct(array $typeMap=array(), $defaultStrategy='\Zend\Soap */ public function connectTypeToStrategy($type, $strategy) { - if(!is_string($type)) { + if (!is_string($type)) { throw new Exception\InvalidArgumentException('Invalid type given to Composite Type Map.'); } $this->typeMap[$type] = $strategy; @@ -85,10 +85,10 @@ public function connectTypeToStrategy($type, $strategy) public function getDefaultStrategy() { $strategy = $this->defaultStrategy; - if(is_string($strategy) && class_exists($strategy)) { + if (is_string($strategy) && class_exists($strategy)) { $strategy = new $strategy; } - if( !($strategy instanceof ComplexTypeStrategy) ) { + if ( !($strategy instanceof ComplexTypeStrategy) ) { throw new Exception\InvalidArgumentException( 'Default Strategy for Complex Types is not a valid strategy object.' ); @@ -106,14 +106,14 @@ public function getDefaultStrategy() */ public function getStrategyOfType($type) { - if(isset($this->typeMap[$type])) { + if (isset($this->typeMap[$type])) { $strategy = $this->typeMap[$type]; - if(is_string($strategy) && class_exists($strategy)) { + if (is_string($strategy) && class_exists($strategy)) { $strategy = new $strategy(); } - if( !($strategy instanceof ComplexTypeStrategy) ) { + if ( !($strategy instanceof ComplexTypeStrategy) ) { throw new Exception\InvalidArgumentException( "Strategy for Complex Type '$type' is not a valid strategy object." ); @@ -145,7 +145,7 @@ public function setContext(Wsdl $context) */ public function addComplexType($type) { - if(!($this->context instanceof Wsdl) ) { + if (!($this->context instanceof Wsdl) ) { throw new Exception\InvalidArgumentException( "Cannot add complex type '$type', no context is set for this composite strategy." ); diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index e0510d2a..8adca6db 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -29,7 +29,7 @@ class DefaultComplexType extends AbstractComplexTypeStrategy */ public function addComplexType($type) { - if(!class_exists($type)) { + if (!class_exists($type)) { throw new Exception\InvalidArgumentException(sprintf( 'Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type diff --git a/test/AutoDiscover/OnlineTest.php b/test/AutoDiscover/OnlineTest.php index 2765f936..df9961f5 100644 --- a/test/AutoDiscover/OnlineTest.php +++ b/test/AutoDiscover/OnlineTest.php @@ -26,7 +26,7 @@ class OnlineTest extends \PHPUnit_Framework_TestCase public function setUp() { - if(!defined('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') || constant('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') == false) { + if (!defined('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') || constant('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') == false) { $this->markTestSkipped('The constant TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI has to be defined to allow the Online test to work.'); } $this->baseuri = TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI; diff --git a/test/TestAsset/fulltests/server1.php b/test/TestAsset/fulltests/server1.php index 3ade9616..98d14332 100644 --- a/test/TestAsset/fulltests/server1.php +++ b/test/TestAsset/fulltests/server1.php @@ -71,7 +71,7 @@ class ComplexTypeA public $baz = array(); } -if(isset($_GET['wsdl'])) { +if (isset($_GET['wsdl'])) { $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; diff --git a/test/TestAsset/fulltests/server2.php b/test/TestAsset/fulltests/server2.php index f0c0951e..5b7d4fee 100644 --- a/test/TestAsset/fulltests/server2.php +++ b/test/TestAsset/fulltests/server2.php @@ -48,7 +48,7 @@ public function request($foo, $bar) } } -if(isset($_GET['wsdl'])) { +if (isset($_GET['wsdl'])) { $server = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; diff --git a/test/_files/fulltests/server1.php b/test/_files/fulltests/server1.php index 1f259bb2..a97f66f4 100644 --- a/test/_files/fulltests/server1.php +++ b/test/_files/fulltests/server1.php @@ -73,7 +73,7 @@ class Zend_Soap_Wsdl_ComplexTypeA public $baz = array(); } -if(isset($_GET['wsdl'])) { +if (isset($_GET['wsdl'])) { $server = new Zend_Soap_AutoDiscover(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; diff --git a/test/_files/fulltests/server2.php b/test/_files/fulltests/server2.php index c4b96d6e..df8790fd 100644 --- a/test/_files/fulltests/server2.php +++ b/test/_files/fulltests/server2.php @@ -50,7 +50,7 @@ public function request($foo, $bar) } } -if(isset($_GET['wsdl'])) { +if (isset($_GET['wsdl'])) { $server = new Zend_Soap_AutoDiscover(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex()); } else { $uri = "http://".$_SERVER['HTTP_HOST']."/".$_SERVER['PHP_SELF']."?wsdl"; From 3e12d7b0aa43e857ffce774c8a72cdb3a15d5afe Mon Sep 17 00:00:00 2001 From: RWOverdijk Date: Thu, 9 Aug 2012 09:54:13 +0200 Subject: [PATCH 113/123] else if --- src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php index 656f0f22..fecaa012 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php @@ -38,7 +38,7 @@ public function addComplexType($type) if ($nestingLevel == 0) { return parent::addComplexType($singularType); - } else if ($nestingLevel == 1) { + } elseif ($nestingLevel == 1) { // The following blocks define the Array of Object structure return $this->_addArrayOfComplexType($singularType, $type); } else { From 6a41e469e8003ef2848429e2cc691368456a73a6 Mon Sep 17 00:00:00 2001 From: Wesley Overdijk Date: Thu, 9 Aug 2012 22:01:34 +0300 Subject: [PATCH 114/123] Update library/Zend/Soap/Server/DocumentLiteralWrapper.php Removed strict check to just make it PRS-2 compliant --- src/Server/DocumentLiteralWrapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server/DocumentLiteralWrapper.php b/src/Server/DocumentLiteralWrapper.php index cc0064b2..5320afa5 100644 --- a/src/Server/DocumentLiteralWrapper.php +++ b/src/Server/DocumentLiteralWrapper.php @@ -148,7 +148,7 @@ protected function _getResultMessage($method, $ret) protected function _assertServiceDelegateHasMethod($method) { - if ($this->reflection->hasMethod($method) !== true) { + if (!$this->reflection->hasMethod($method)) { throw new BadMethodCallException(sprintf( "Method %s does not exist on delegate object %s", $method, get_class($this->object) From c87be127dd38b4f8c21d56e6e3055aa8f708fb56 Mon Sep 17 00:00:00 2001 From: Michael Kliewe Date: Sat, 11 Aug 2012 11:27:30 +0200 Subject: [PATCH 115/123] removed all "@return void" in constructors --- src/Server.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Server.php b/src/Server.php index c7af8add..5b1be333 100644 --- a/src/Server.php +++ b/src/Server.php @@ -144,7 +144,6 @@ class Server implements \Zend\Server\Server * * @param string $wsdl * @param array $options - * @return void * @throws Exception\ExtensionNotLoadedException */ public function __construct($wsdl = null, array $options = null) From d2eaf12b2b933b56942932f011d2dc3b3ce59858 Mon Sep 17 00:00:00 2001 From: Michael Kliewe Date: Sat, 11 Aug 2012 12:29:21 +0200 Subject: [PATCH 116/123] added @return where missing fixed @return where wrong fixed @param where wrong in methods: @var -> @param --- src/Client.php | 6 ++++-- src/Client/DotNet.php | 1 + src/Server.php | 4 +++- src/Wsdl/ComplexTypeStrategy/Composite.php | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index c6d238d3..2a866fbb 100644 --- a/src/Client.php +++ b/src/Client.php @@ -998,6 +998,7 @@ protected function _initSoapClientObject() * My be overridden in descendant classes * * @param array $arguments + * @return array */ protected function _preProcessArguments($arguments) { @@ -1010,7 +1011,8 @@ protected function _preProcessArguments($arguments) * * My be overridden in descendant classes * - * @param array $arguments + * @param array $result + * @return array */ protected function _preProcessResult($result) { @@ -1021,7 +1023,7 @@ protected function _preProcessResult($result) /** * Add SOAP input header * - * @param SoapHeader $header + * @param \SoapHeader $header * @param boolean $permanent * @return \Zend\Soap\Client */ diff --git a/src/Client/DotNet.php b/src/Client/DotNet.php index f5274e2c..112968cc 100644 --- a/src/Client/DotNet.php +++ b/src/Client/DotNet.php @@ -70,6 +70,7 @@ protected function _preProcessArguments($arguments) * My be overridden in descendant classes * * @param object $result + * @return mixed */ protected function _preProcessResult($result) { diff --git a/src/Server.php b/src/Server.php index 5b1be333..f0614d11 100644 --- a/src/Server.php +++ b/src/Server.php @@ -452,7 +452,7 @@ public function getSoapFeatures() /** * Set the SOAP WSDL Caching Options * - * @param string|int|boolean $caching + * @param string|int|boolean $options * @return Server */ public function setWSDLCache($options) @@ -518,6 +518,8 @@ public function addFunction($function, $namespace = '') * See {@link setObject()} to set preconfigured object instances as request handlers. * * @param string|object $class Class name or object instance which executes SOAP Requests at endpoint. + * @param string $namespace + * @param $argv * @return Server * @throws Exception\InvalidArgumentException if called more than once, or if class * does not exist diff --git a/src/Wsdl/ComplexTypeStrategy/Composite.php b/src/Wsdl/ComplexTypeStrategy/Composite.php index 9fd9ceb3..b4a2419f 100644 --- a/src/Wsdl/ComplexTypeStrategy/Composite.php +++ b/src/Wsdl/ComplexTypeStrategy/Composite.php @@ -129,6 +129,7 @@ public function getStrategyOfType($type) * Method accepts the current WSDL context file. * * @param \Zend\Soap\Wsdl $context + * @return Composite */ public function setContext(Wsdl $context) { From 5ab82360c74edabef598f972417c6e16a8f8d941 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 17 Aug 2012 11:48:41 -0500 Subject: [PATCH 117/123] Fixed issue with soap faults - Basically, calling $soapServer->fault() causes the script to end -- see https://bugs.php.net/bug.php?id=49513 - Workaround is to manually instantiate the SoapFault, and set that as the response. When you echo it, it will send headers and the payload. This makes it testable. --- src/Server.php | 12 ++++++++---- test/ServerTest.php | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Server.php b/src/Server.php index 05f0bb71..347e8aa9 100644 --- a/src/Server.php +++ b/src/Server.php @@ -798,16 +798,16 @@ public function handle($request = null) $soap = $this->_getSoap(); + $fault = false; ob_start(); if ($setRequestException instanceof \Exception) { - // Send SOAP fault message if we've catched exception - $soap->fault('Sender', $setRequestException->getMessage()); + // Create SOAP fault message if we've caught a request exception + $fault = $this->fault($setRequestException->getMessage(), 'Sender'); } else { try { $soap->handle($this->request); } catch (\Exception $e) { $fault = $this->fault($e); - $soap->fault($fault->faultcode, $fault->faultstring); } } $this->response = ob_get_clean(); @@ -816,8 +816,12 @@ public function handle($request = null) restore_error_handler(); ini_set('display_errors', $displayErrorsOriginalState); + // Send a fault, if we have one + if ($fault) { + $this->response = $fault; + } + if (!$this->returnResponse) { - echo $this->response; return; } diff --git a/test/ServerTest.php b/test/ServerTest.php index f614ca7c..3b8796fe 100644 --- a/test/ServerTest.php +++ b/test/ServerTest.php @@ -858,6 +858,9 @@ public function testHandleUsesProperRequestParameter() $this->assertTrue(is_string($server->mockSoapServer->handle[0])); } + /** + * @runInSeparateProcess + */ public function testShouldThrowExceptionIfHandledRequestContainsDoctype() { $server = new Server(); @@ -881,7 +884,7 @@ public function testShouldThrowExceptionIfHandledRequestContainsDoctype() . '' . '' . "\n"; $response = $server->handle($request); - $this->assertContains($response, 'Invalid XML'); + $this->assertContains('Invalid XML', $response->getMessage()); } } From 7c38895b4fff8cf3ff4c396a656bd41255339523 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 17 Aug 2012 12:16:48 -0500 Subject: [PATCH 118/123] Pull response from server if output buffer is empty - Ensures that methods not outputting content can still have responses aggregated --- src/Client/Local.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Client/Local.php b/src/Client/Local.php index c482d067..380ddf66 100644 --- a/src/Client/Local.php +++ b/src/Client/Local.php @@ -70,6 +70,13 @@ public function _doRequest(Common $client, $request, $location, $action, $versio $this->server->handle($request); $response = ob_get_clean(); + if ($response === null || $response === '') { + $serverResponse = $this->server->getResponse(); + if ($serverResponse !== null) { + $response = $serverResponse; + } + } + return $response; } } From 073ffb172f17237f3ff44a6b1c7c2ad5290cc8a3 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 17 Aug 2012 12:56:06 -0500 Subject: [PATCH 119/123] When returnResponse is false, echo the response --- src/Server.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Server.php b/src/Server.php index 347e8aa9..8a609a1b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -822,6 +822,7 @@ public function handle($request = null) } if (!$this->returnResponse) { + echo $this->response; return; } From 9459fb3c8a289be405f04f470f69fc50c5b97ad5 Mon Sep 17 00:00:00 2001 From: Michel Hunziker Date: Fri, 31 Aug 2012 17:30:38 +0200 Subject: [PATCH 120/123] Add missing @throws annotations --- src/Server.php | 3 +++ src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php | 1 + src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php | 1 + 3 files changed, 5 insertions(+) diff --git a/src/Server.php b/src/Server.php index 8a609a1b..5ba38a79 100644 --- a/src/Server.php +++ b/src/Server.php @@ -557,6 +557,7 @@ public function setClass($class, $namespace = '', $argv = null) * Accepts an instanciated object to use when handling requests. * * @param object $object + * @throws Exception\InvalidArgumentException * @return Server */ public function setObject($object) @@ -612,6 +613,7 @@ public function loadFunctions($definition) * Set server persistence * * @param int $mode + * @throws Exception\InvalidArgumentException * @return Server */ public function setPersistence($mode) @@ -645,6 +647,7 @@ public function getPersistence() * - string; if so, verifies XML * * @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request + * @throws Exception\InvalidArgumentException * @return Server */ protected function _setRequest($request) diff --git a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php index fecaa012..116ae818 100644 --- a/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php +++ b/src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.php @@ -25,6 +25,7 @@ class ArrayOfTypeComplex extends DefaultComplexType * Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment. * * @param string $type + * @throws Exception\InvalidArgumentException * @return string tns:xsd-type */ public function addComplexType($type) diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index 8adca6db..65820701 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -25,6 +25,7 @@ class DefaultComplexType extends AbstractComplexTypeStrategy * Add a complex type by recursivly using all the class properties fetched via Reflection. * * @param string $type Name of the class to be specified + * @throws Exception\InvalidArgumentException if class does not exist * @return string XSD Type for the given PHP type */ public function addComplexType($type) From 1b4845b19540d8ea7bda4d403a01620da58571e5 Mon Sep 17 00:00:00 2001 From: Michel Hunziker Date: Fri, 31 Aug 2012 19:52:32 +0200 Subject: [PATCH 121/123] Resolve undefined classes in phpDoc --- src/AutoDiscover.php | 2 +- src/Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index c8d4f170..579e3f2b 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -507,7 +507,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) /** * Generate the WSDL file from the configured input. * - * @return Zend_Wsdl + * @return Wsdl */ public function generate() { diff --git a/src/Client.php b/src/Client.php index e5004250..bf81fc6a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1140,7 +1140,7 @@ public function getTypes() } /** - * @param SoapClient $soapClient + * @param \SoapClient $soapClient * @return \Zend\Soap\Client */ public function setSoapClient(\SoapClient $soapClient) From beca8cf2f5557dc7be2af6a3566222397b273954 Mon Sep 17 00:00:00 2001 From: Michel Hunziker Date: Sat, 1 Sep 2012 20:40:03 +0200 Subject: [PATCH 122/123] Resolve more mismatched phpDoc --- src/AutoDiscover.php | 2 ++ src/Client.php | 3 ++- src/Client/Common.php | 2 +- src/Server.php | 2 +- src/Wsdl.php | 4 +++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 579e3f2b..77ab98bd 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -106,6 +106,7 @@ class AutoDiscover * @param ComplexTypeStrategy $strategy * @param string|Uri\Uri $endpointUri * @param string $wsdlClass + * @param array $classMap */ public function __construct(ComplexTypeStrategy $strategy = null, $endpointUri=null, $wsdlClass=null, array $classMap = array()) { @@ -368,6 +369,7 @@ protected function _generateFunctions() /** * Generate the WSDL for a set of reflection method instances. * + * @param array $reflectionMethods * @return Zend\Soap\Wsdl */ protected function _generateWsdl(array $reflectionMethods) diff --git a/src/Client.php b/src/Client.php index bf81fc6a..d31981c1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -666,7 +666,7 @@ public function getProxyLogin() /** * Set proxy password * - * @param string $proxyLogin + * @param string $proxyPassword * @return \Zend\Soap\Client */ public function setProxyPassword($proxyPassword) @@ -774,6 +774,7 @@ public function getProxyPassword() /** * Set Stream Context * + * @param resource $context * @return \Zend\Soap\Client */ public function setStreamContext($context) diff --git a/src/Client/Common.php b/src/Client/Common.php index 6678c7df..779264da 100644 --- a/src/Client/Common.php +++ b/src/Client/Common.php @@ -29,7 +29,7 @@ class Common extends \SoapClient /** * Common Soap Client constructor * - * @param callable $doRequestMethod + * @param callable $doRequestCallback * @param string $wsdl * @param array $options */ diff --git a/src/Server.php b/src/Server.php index 5ba38a79..babd3bb1 100644 --- a/src/Server.php +++ b/src/Server.php @@ -600,7 +600,7 @@ public function getFunctions() /** * Unimplemented: Load server definition * - * @param array $array + * @param array $definition * @return void * @throws Exception\RuntimeException Unimplemented */ diff --git a/src/Wsdl.php b/src/Wsdl.php index 59d9aa7b..c9fdbded 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -67,7 +67,9 @@ class Wsdl * * @param string $name Name of the Web Service being Described * @param string|Uri $uri URI where the WSDL will be available - * @param ComplexTypeStrategy $strategy + * @param null|ComplexTypeStrategy $strategy Strategy for detection of complex types + * @param null|array $classMap Map of PHP Class names to WSDL QNames + * @throws Exception\RuntimeException */ public function __construct($name, $uri, ComplexTypeStrategy $strategy = null, array $classMap = array()) { From 273588955ba899f41c8181cce64821dbbbc50f62 Mon Sep 17 00:00:00 2001 From: Michel Hunziker Date: Sat, 1 Sep 2012 22:09:27 +0200 Subject: [PATCH 123/123] Add more missing @throws annotations --- src/AutoDiscover.php | 2 ++ src/Server/DocumentLiteralWrapper.php | 1 + src/Wsdl.php | 1 + 3 files changed, 4 insertions(+) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 77ab98bd..0fa3fafd 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -402,6 +402,7 @@ protected function _generateWsdl(array $reflectionMethods) * @param $wsdl \Zend\Soap\Wsdl WSDL document * @param $port object wsdl:portType * @param $binding object wsdl:binding + * @throws Exception\InvalidArgumentException * @return void */ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) @@ -509,6 +510,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding) /** * Generate the WSDL file from the configured input. * + * @throws Exception\RuntimeException * @return Wsdl */ public function generate() diff --git a/src/Server/DocumentLiteralWrapper.php b/src/Server/DocumentLiteralWrapper.php index 5320afa5..6b021065 100644 --- a/src/Server/DocumentLiteralWrapper.php +++ b/src/Server/DocumentLiteralWrapper.php @@ -118,6 +118,7 @@ public function __call($method, $args) * * @param string $method * @param object $document + * @throws UnexpectedValueException * @return array */ protected function _parseArguments($method, $document) diff --git a/src/Wsdl.php b/src/Wsdl.php index c9fdbded..8eb4a053 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -628,6 +628,7 @@ public function addComplexType($type) * Parse an xsd:element represented as an array into a DOMElement. * * @param array $element an xsd:element represented as an array + * @throws Exception\RuntimeException if $element is not an array * @return DOMElement parsed element */ private function _parseElement($element)