From ede3ed54ae5e98ac9709a98e5f359376dbe53d39 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Thu, 3 Oct 2024 14:11:13 +0200 Subject: [PATCH] First commit --- .gitattributes | 14 + .github/dependabot.yml | 29 ++ .github/workflows/autolock-conversations.yml | 25 ++ .github/workflows/documentation.yml | 35 ++ .github/workflows/php.yml | 280 ++++++++++++++++ .gitignore | 7 +- .markdownlintignore | 1 + .markdownlintrc | 1 + codecov.yml | 20 ++ composer.json | 45 +++ phpcs.xml | 17 + phpstan-dev.neon | 4 + phpstan.neon | 4 + phpunit.xml | 19 ++ resources/schemas/wsdl.xsd | 310 ++++++++++++++++++ src/Constants.php | 19 ++ src/XML/element.registry.php | 9 + src/XML/wsdl/AbstractBinding.php | 104 ++++++ src/XML/wsdl/AbstractBindingOperation.php | 118 +++++++ .../wsdl/AbstractBindingOperationFault.php | 69 ++++ .../wsdl/AbstractBindingOperationMessage.php | 71 ++++ src/XML/wsdl/AbstractDefinitions.php | 269 +++++++++++++++ src/XML/wsdl/AbstractDocumented.php | 63 ++++ src/XML/wsdl/AbstractExtensibilityElement.php | 54 +++ ...AbstractExtensibleAttributesDocumented.php | 63 ++++ src/XML/wsdl/AbstractExtensibleDocumented.php | 62 ++++ src/XML/wsdl/AbstractFault.php | 86 +++++ src/XML/wsdl/AbstractImport.php | 86 +++++ src/XML/wsdl/AbstractMessage.php | 98 ++++++ src/XML/wsdl/AbstractParam.php | 89 +++++ src/XML/wsdl/AbstractPart.php | 107 ++++++ src/XML/wsdl/AbstractPort.php | 86 +++++ src/XML/wsdl/AbstractPortType.php | 89 +++++ src/XML/wsdl/AbstractPortTypeOperation.php | 132 ++++++++ src/XML/wsdl/AbstractService.php | 99 ++++++ src/XML/wsdl/AbstractTypes.php | 24 ++ src/XML/wsdl/AbstractWsdlElement.php | 22 ++ src/XML/wsdl/Binding.php | 45 +++ src/XML/wsdl/BindingOperation.php | 50 +++ src/XML/wsdl/BindingOperationFault.php | 41 +++ src/XML/wsdl/BindingOperationInput.php | 41 +++ src/XML/wsdl/BindingOperationOutput.php | 41 +++ src/XML/wsdl/Definitions.php | 48 +++ src/XML/wsdl/Fault.php | 42 +++ src/XML/wsdl/Import.php | 42 +++ src/XML/wsdl/Input.php | 42 +++ src/XML/wsdl/Message.php | 42 +++ src/XML/wsdl/Output.php | 42 +++ src/XML/wsdl/Part.php | 43 +++ src/XML/wsdl/Port.php | 42 +++ src/XML/wsdl/PortType.php | 42 +++ src/XML/wsdl/PortTypeOperation.php | 80 +++++ src/XML/wsdl/Service.php | 42 +++ src/XML/wsdl/Types.php | 40 +++ tests/WSDL/Constants.php | 15 + tests/WSDL/XML/wsdl/BindingOperationTest.php | 95 ++++++ tests/WSDL/XML/wsdl/BindingTest.php | 107 ++++++ tests/WSDL/XML/wsdl/DefinitionsTest.php | 192 +++++++++++ tests/WSDL/XML/wsdl/FaultTest.php | 65 ++++ tests/WSDL/XML/wsdl/ImportTest.php | 65 ++++ tests/WSDL/XML/wsdl/InputTest.php | 67 ++++ tests/WSDL/XML/wsdl/MessageTest.php | 89 +++++ tests/WSDL/XML/wsdl/OutputTest.php | 67 ++++ tests/WSDL/XML/wsdl/PartTest.php | 65 ++++ tests/WSDL/XML/wsdl/PortTest.php | 66 ++++ .../XML/wsdl/PortTypeOperationInputTest.php | 77 +++++ .../XML/wsdl/PortTypeOperationOutputTest.php | 77 +++++ tests/WSDL/XML/wsdl/PortTypeTest.php | 82 +++++ tests/WSDL/XML/wsdl/ServiceTest.php | 77 +++++ tests/WSDL/XML/wsdl/TypesTest.php | 67 ++++ tests/bootstrap.php | 9 + tests/resources/xml/wsdl/Binding.xml | 19 ++ tests/resources/xml/wsdl/BindingOperation.xml | 15 + tests/resources/xml/wsdl/Definitions.xml | 39 +++ tests/resources/xml/wsdl/Fault.xml | 1 + tests/resources/xml/wsdl/Import.xml | 1 + tests/resources/xml/wsdl/Input.xml | 1 + tests/resources/xml/wsdl/Message.xml | 5 + tests/resources/xml/wsdl/Output.xml | 1 + tests/resources/xml/wsdl/Part.xml | 1 + tests/resources/xml/wsdl/Port.xml | 3 + tests/resources/xml/wsdl/PortType.xml | 12 + .../xml/wsdl/PortTypeOperation_Input.xml | 5 + .../xml/wsdl/PortTypeOperation_Output.xml | 5 + tests/resources/xml/wsdl/Service.xml | 9 + tests/resources/xml/wsdl/Types.xml | 3 + tools/linters/.yaml-lint.yml | 7 + 87 files changed, 4802 insertions(+), 2 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/autolock-conversations.yml create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/php.yml create mode 100644 .markdownlintignore create mode 100644 .markdownlintrc create mode 100644 codecov.yml create mode 100644 composer.json create mode 100644 phpcs.xml create mode 100644 phpstan-dev.neon create mode 100644 phpstan.neon create mode 100644 phpunit.xml create mode 100644 resources/schemas/wsdl.xsd create mode 100644 src/Constants.php create mode 100644 src/XML/element.registry.php create mode 100644 src/XML/wsdl/AbstractBinding.php create mode 100644 src/XML/wsdl/AbstractBindingOperation.php create mode 100644 src/XML/wsdl/AbstractBindingOperationFault.php create mode 100644 src/XML/wsdl/AbstractBindingOperationMessage.php create mode 100644 src/XML/wsdl/AbstractDefinitions.php create mode 100644 src/XML/wsdl/AbstractDocumented.php create mode 100644 src/XML/wsdl/AbstractExtensibilityElement.php create mode 100644 src/XML/wsdl/AbstractExtensibleAttributesDocumented.php create mode 100644 src/XML/wsdl/AbstractExtensibleDocumented.php create mode 100644 src/XML/wsdl/AbstractFault.php create mode 100644 src/XML/wsdl/AbstractImport.php create mode 100644 src/XML/wsdl/AbstractMessage.php create mode 100644 src/XML/wsdl/AbstractParam.php create mode 100644 src/XML/wsdl/AbstractPart.php create mode 100644 src/XML/wsdl/AbstractPort.php create mode 100644 src/XML/wsdl/AbstractPortType.php create mode 100644 src/XML/wsdl/AbstractPortTypeOperation.php create mode 100644 src/XML/wsdl/AbstractService.php create mode 100644 src/XML/wsdl/AbstractTypes.php create mode 100644 src/XML/wsdl/AbstractWsdlElement.php create mode 100644 src/XML/wsdl/Binding.php create mode 100644 src/XML/wsdl/BindingOperation.php create mode 100644 src/XML/wsdl/BindingOperationFault.php create mode 100644 src/XML/wsdl/BindingOperationInput.php create mode 100644 src/XML/wsdl/BindingOperationOutput.php create mode 100644 src/XML/wsdl/Definitions.php create mode 100644 src/XML/wsdl/Fault.php create mode 100644 src/XML/wsdl/Import.php create mode 100644 src/XML/wsdl/Input.php create mode 100644 src/XML/wsdl/Message.php create mode 100644 src/XML/wsdl/Output.php create mode 100644 src/XML/wsdl/Part.php create mode 100644 src/XML/wsdl/Port.php create mode 100644 src/XML/wsdl/PortType.php create mode 100644 src/XML/wsdl/PortTypeOperation.php create mode 100644 src/XML/wsdl/Service.php create mode 100644 src/XML/wsdl/Types.php create mode 100644 tests/WSDL/Constants.php create mode 100644 tests/WSDL/XML/wsdl/BindingOperationTest.php create mode 100644 tests/WSDL/XML/wsdl/BindingTest.php create mode 100644 tests/WSDL/XML/wsdl/DefinitionsTest.php create mode 100644 tests/WSDL/XML/wsdl/FaultTest.php create mode 100644 tests/WSDL/XML/wsdl/ImportTest.php create mode 100644 tests/WSDL/XML/wsdl/InputTest.php create mode 100644 tests/WSDL/XML/wsdl/MessageTest.php create mode 100644 tests/WSDL/XML/wsdl/OutputTest.php create mode 100644 tests/WSDL/XML/wsdl/PartTest.php create mode 100644 tests/WSDL/XML/wsdl/PortTest.php create mode 100644 tests/WSDL/XML/wsdl/PortTypeOperationInputTest.php create mode 100644 tests/WSDL/XML/wsdl/PortTypeOperationOutputTest.php create mode 100644 tests/WSDL/XML/wsdl/PortTypeTest.php create mode 100644 tests/WSDL/XML/wsdl/ServiceTest.php create mode 100644 tests/WSDL/XML/wsdl/TypesTest.php create mode 100644 tests/bootstrap.php create mode 100644 tests/resources/xml/wsdl/Binding.xml create mode 100644 tests/resources/xml/wsdl/BindingOperation.xml create mode 100644 tests/resources/xml/wsdl/Definitions.xml create mode 100644 tests/resources/xml/wsdl/Fault.xml create mode 100644 tests/resources/xml/wsdl/Import.xml create mode 100644 tests/resources/xml/wsdl/Input.xml create mode 100644 tests/resources/xml/wsdl/Message.xml create mode 100644 tests/resources/xml/wsdl/Output.xml create mode 100644 tests/resources/xml/wsdl/Part.xml create mode 100644 tests/resources/xml/wsdl/Port.xml create mode 100644 tests/resources/xml/wsdl/PortType.xml create mode 100644 tests/resources/xml/wsdl/PortTypeOperation_Input.xml create mode 100644 tests/resources/xml/wsdl/PortTypeOperation_Output.xml create mode 100644 tests/resources/xml/wsdl/Service.xml create mode 100644 tests/resources/xml/wsdl/Types.xml create mode 100644 tools/linters/.yaml-lint.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2beb425 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +/.github/ export-ignore +/tools/ export-ignore +/tests/ export-ignore +codecov.yml export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +phpstan.neon export-ignore +phpstan-dev.neon export-ignore +phpcs.xml export-ignore +phpunit.xml export-ignore +.php_cs.dist export-ignore +.markdownlintignore export-ignore +.markdownlintrc export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7fcaf10 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +--- + +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + groups: + all-actions: + patterns: ["*"] + + - package-ecosystem: "composer" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major"] + groups: + production-dependencies: + dependency-type: "production" + dev-dependencies: + dependency-type: "development" diff --git a/.github/workflows/autolock-conversations.yml b/.github/workflows/autolock-conversations.yml new file mode 100644 index 0000000..3c7be52 --- /dev/null +++ b/.github/workflows/autolock-conversations.yml @@ -0,0 +1,25 @@ +--- + +name: 'Lock Threads' + +on: # yamllint disable-line rule:truthy + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + +permissions: + issues: write + pull-requests: write + +concurrency: + group: lock + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v5 + with: + issue-inactive-days: '90' + pr-inactive-days: '90' + log-output: true diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..c477bc6 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,35 @@ +--- + +name: Documentation + +on: # yamllint disable-line rule:truthy + push: + branches: [master, release-*] + paths: + - '**.md' + pull_request: + branches: [master, release-*] + paths: + - '**.md' + workflow_dispatch: + +jobs: + quality: + name: Quality checks + runs-on: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Lint markdown files + uses: nosborn/github-action-markdown-cli@v3 + with: + files: . + ignore_path: .markdownlintignore + + - name: Perform spell check + uses: codespell-project/actions-codespell@v2 + with: + path: '**/*.md' + check_filenames: true + ignore_words_list: tekst diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..202a2ff --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,280 @@ +--- + +name: CI + +on: # yamllint disable-line rule:truthy + push: + branches: ['**'] + paths-ignore: + - '**.md' + pull_request: + branches: [master, release-*] + paths-ignore: + - '**.md' + workflow_dispatch: + +jobs: + linter: + name: Linter + runs-on: ['ubuntu-latest'] + + steps: + - uses: actions/checkout@v4 + with: + # super-linter needs the full git history to get the + # list of files that changed across commits + fetch-depth: 0 + + - name: Lint Code Base + uses: super-linter/super-linter/slim@v7 + env: + # To report GitHub Actions status checks + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: 'tools/linters' + LOG_LEVEL: NOTICE + VALIDATE_ALL_CODEBASE: true + VALIDATE_JSON: true + VALIDATE_PHP_BUILTIN: true + VALIDATE_YAML: true + VALIDATE_XML: true + VALIDATE_GITHUB_ACTIONS: true + + quality: + name: Quality control + runs-on: [ubuntu-latest] + + steps: + - name: Setup PHP, with composer and extensions + id: setup-php + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + # Should be the higest supported version, so we can use the newest tools + php-version: '8.3' + tools: composer, composer-require-checker, composer-unused, phpcs, phpstan + extensions: ctype, date, dom, filter, pcre, soap, spl, xml + coverage: none + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Check code for hard dependencies missing in composer.json + run: composer-require-checker check composer.json + + - name: Check code for unused dependencies in composer.json + run: composer-unused + + - name: PHP Code Sniffer + run: phpcs + + - name: PHPStan + run: | + phpstan analyze -c phpstan.neon + + - name: PHPStan (testsuite) + run: | + phpstan analyze -c phpstan-dev.neon + + security: + name: Security checks + runs-on: [ubuntu-latest] + steps: + - name: Setup PHP, with composer and extensions + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + # Should be the lowest supported version + php-version: '8.1' + extensions: ctype, date, dom, filter, pcre, soap, spl, xml + tools: composer + coverage: none + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Security check for locked dependencies + run: composer audit + + - name: Update Composer dependencies + run: composer update --no-progress --prefer-dist --optimize-autoloader + + - name: Security check for updated dependencies + run: composer audit + + unit-tests-linux: + name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}" + runs-on: ${{ matrix.operating-system }} + needs: [linter, quality, security] + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest] + php-versions: ['8.1', '8.2', '8.3'] + + steps: + - name: Setup PHP, with composer and extensions + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: ctype, date, dom, filter, pcre, soap, spl, xml + tools: composer + ini-values: error_reporting=E_ALL + coverage: pcov + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Run unit tests with coverage + if: ${{ matrix.php-versions == '8.3' }} + run: vendor/bin/phpunit + + - name: Run unit tests (no coverage) + if: ${{ matrix.php-versions != '8.3' }} + run: vendor/bin/phpunit --no-coverage + + - name: Save coverage data + if: ${{ matrix.php-versions == '8.3' }} + uses: actions/upload-artifact@v4 + with: + name: coverage-data + path: ${{ github.workspace }}/build + + unit-tests-windows: + name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}" + runs-on: ${{ matrix.operating-system }} + needs: [linter, quality, security] + strategy: + fail-fast: true + matrix: + operating-system: [windows-latest] + php-versions: ['8.1', '8.2', '8.3'] + + steps: + - name: Setup PHP, with composer and extensions + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: ctype, date, dom, filter, pcre, soap, spl, xml + tools: composer + ini-values: error_reporting=E_ALL + coverage: none + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Run unit tests + run: vendor/bin/phpunit --no-coverage + + coverage: + name: Code coverage + runs-on: [ubuntu-latest] + needs: [unit-tests-linux] + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: coverage-data + path: ${{ github.workspace }}/build + + - name: Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true + + cleanup: + name: Cleanup artifacts + needs: [unit-tests-linux, coverage] + runs-on: [ubuntu-latest] + if: | + always() && + needs.coverage.result == 'success' || + (needs.unit-tests-linux.result == 'success' && needs.coverage.result == 'skipped') + + steps: + - uses: geekyeggo/delete-artifact@v5 + with: + name: coverage-data diff --git a/.gitignore b/.gitignore index a67d42b..b6d8111 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ -composer.phar +/.phpunit.cache/ +/build/ /vendor/ +.phpunit.result.cache +composer.phar +composer.lock # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 0000000..140fada --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1 @@ +vendor/* diff --git a/.markdownlintrc b/.markdownlintrc new file mode 100644 index 0000000..140fada --- /dev/null +++ b/.markdownlintrc @@ -0,0 +1 @@ +vendor/* diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..fe6a1cf --- /dev/null +++ b/codecov.yml @@ -0,0 +1,20 @@ +--- + +coverage: + status: + project: + default: + target: 0% + threshold: 2% + patch: false +comment: + layout: "diff" + behavior: once + require_changes: true + require_base: false + require_head: true + branches: null +github_checks: + annotations: false +ignore: + - 'src/XML/element.registry.php' diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..15d3b1e --- /dev/null +++ b/composer.json @@ -0,0 +1,45 @@ +{ + "name": "simplesamlphp/xml-wsdl", + "description": "SimpleSAMLphp library for Web Services Description Language", + "license": "LGPL-2.1-or-later", + "authors": [ + { + "name": "Tim van Dijen", + "email": "tvdijen@gmail.com" + } + ], + "require": { + "php": "^8.1", + "ext-dom": "*", + "ext-spl": "*", + + "simplesamlphp/assert": "^1.0", + "simplesamlphp/xml-common": "^1.16" + }, + "require-dev": { + "simplesamlphp/simplesamlphp-test-framework": "^1.7" + }, + "autoload": { + "psr-4": { + "SimpleSAML\\WSDL\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "SimpleSAML\\Test\\WSDL\\": "tests/WSDL/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "v1.0.x-dev" + } + }, + "config": { + "allow-plugins": { + "composer/package-versions-deprecated": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true, + "simplesamlphp/composer-xmlprovider-installer": true + } + } +} diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..1626063 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,17 @@ + + + + By default it is less stringent about long lines than other coding standards + + + + + + + src + tests/WSDL + + + + + diff --git a/phpstan-dev.neon b/phpstan-dev.neon new file mode 100644 index 0000000..508f5d0 --- /dev/null +++ b/phpstan-dev.neon @@ -0,0 +1,4 @@ +parameters: + level: 4 + paths: + - tests diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..db37782 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 6 + paths: + - src diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..90c2e60 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + + + + + + + ./tests/WSDL + + + + + + ./src + + + diff --git a/resources/schemas/wsdl.xsd b/resources/schemas/wsdl.xsd new file mode 100644 index 0000000..b69c377 --- /dev/null +++ b/resources/schemas/wsdl.xsd @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + 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 diff --git a/src/Constants.php b/src/Constants.php new file mode 100644 index 0000000..4d25299 --- /dev/null +++ b/src/Constants.php @@ -0,0 +1,19 @@ + [ + 'definitions' => '\SimpleSAML\WSSecurity\XML\wsdl\Definitions', + ], +]; diff --git a/src/XML/wsdl/AbstractBinding.php b/src/XML/wsdl/AbstractBinding.php new file mode 100644 index 0000000..b8dfaae --- /dev/null +++ b/src/XML/wsdl/AbstractBinding.php @@ -0,0 +1,104 @@ +name; + } + + + /** + * Collect the value of the type-property. + * + * @return string + */ + public function getType(): string + { + return $this->type; + } + + + /** + * Collect the value of the operation-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\BindingOperation[] + */ + public function getOperation(): array + { + return $this->operation; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tBinding to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tBinding. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + $e->setAttribute('type', $this->getType()); + + foreach ($this->getOperation() as $operation) { + $operation->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractBindingOperation.php b/src/XML/wsdl/AbstractBindingOperation.php new file mode 100644 index 0000000..694ca2d --- /dev/null +++ b/src/XML/wsdl/AbstractBindingOperation.php @@ -0,0 +1,118 @@ +name; + } + + + /** + * Collect the value of the input-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\BindingOperationInput|null + */ + public function getInput(): ?BindingOperationInput + { + return $this->input; + } + + + /** + * Collect the value of the output-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\BindingOperationOutput|null + */ + public function getOutput(): ?BindingOperationOutput + { + return $this->output; + } + + + /** + * Collect the value of the fault-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\BindingOperationFault[] + */ + public function getFault(): array + { + return $this->fault; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tBindingOperation to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tBindingOperation. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + + $this->getInput()?->toXML($e); + $this->getOutput()?->toXML($e); + + foreach ($this->getFault() as $fault) { + $fault->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractBindingOperationFault.php b/src/XML/wsdl/AbstractBindingOperationFault.php new file mode 100644 index 0000000..092b6e3 --- /dev/null +++ b/src/XML/wsdl/AbstractBindingOperationFault.php @@ -0,0 +1,69 @@ +name; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tBindingOperationFault to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tBindingOperationFault. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + $e->setAttribute('name', $this->getName()); + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractBindingOperationMessage.php b/src/XML/wsdl/AbstractBindingOperationMessage.php new file mode 100644 index 0000000..23cec22 --- /dev/null +++ b/src/XML/wsdl/AbstractBindingOperationMessage.php @@ -0,0 +1,71 @@ +name; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return parent::isEmptyElement() && empty($this->getName()); + } + + + /** + * Convert this tBindingOperationMessage to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tBindingOperationMessage. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + if ($this->getName() !== null) { + $e->setAttribute('name', $this->getName()); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractDefinitions.php b/src/XML/wsdl/AbstractDefinitions.php new file mode 100644 index 0000000..63d1670 --- /dev/null +++ b/src/XML/wsdl/AbstractDefinitions.php @@ -0,0 +1,269 @@ +getName(); + }, + $message, + ); + Assert::uniqueValues( + $messageNames, + "Message-elements must have unique names.", + SchemaViolationException::class, + ); + + $portTypeNames = array_map( + function ($x) { + return $x->getName(); + }, + $portType, + ); + Assert::uniqueValues( + $portTypeNames, + "PortType-elements must have unique names.", + SchemaViolationException::class, + ); + + $bindingNames = array_map( + function ($x) { + return $x->getName(); + }, + $binding, + ); + Assert::uniqueValues( + $bindingNames, + "Binding-elements must have unique names.", + SchemaViolationException::class, + ); + + $serviceNames = array_map( + function ($x) { + return $x->getName(); + }, + $service, + ); + Assert::uniqueValues( + $serviceNames, + "Service-elements must have unique names.", + SchemaViolationException::class, + ); + + $importNamespaces = array_map( + function ($x) { + return $x->getNamespace(); + }, + $import, + ); + Assert::uniqueValues( + $importNamespaces, + "Import-elements must have unique namespaces.", + SchemaViolationException::class, + ); + + parent::__construct($elements); + } + + + /** + * Collect the value of the name-property. + * + * @return string|null + */ + public function getName(): ?string + { + return $this->name; + } + + + /** + * Collect the value of the targetNamespace-property. + * + * @return string|null + */ + public function getTargetNamespace(): ?string + { + return $this->targetNamespace; + } + + + /** + * Collect the value of the import-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Import[] + */ + public function getImport(): array + { + return $this->import; + } + + + /** + * Collect the value of the typrd-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Types[] + */ + public function getTypes(): array + { + return $this->types; + } + + + /** + * Collect the value of the message-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Message[] + */ + public function getMessage(): array + { + return $this->message; + } + + + /** + * Collect the value of the portType-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\PortType[] + */ + public function getPortType(): array + { + return $this->portType; + } + + + /** + * Collect the value of the binding-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Binding[] + */ + public function getBinding(): array + { + return $this->binding; + } + + + /** + * Collect the value of the service-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Service[] + */ + public function getService(): array + { + return $this->service; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return parent::isEmptyElement() && + empty($this->getName()) && + empty($this->getTargetNamespace()) && + empty($this->getImport()) && + empty($this->getTypes()) && + empty($this->getMessage()) && + empty($this->getPortType()) && + empty($this->getBinding()) && + empty($this->getService()); + } + + + /** + * Convert this tDefinitions to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tDefinitions. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + if ($this->getTargetNamespace() !== null) { + $e->setAttribute('targetNamespace', $this->getTargetNamespace()); + } + + if ($this->getName() !== null) { + $e->setAttribute('name', $this->getName()); + } + + foreach ($this->getImport() as $import) { + $import->toXML($e); + } + + foreach ($this->getTypes() as $types) { + $types->toXML($e); + } + + foreach ($this->getMessage() as $message) { + $message->toXML($e); + } + + foreach ($this->getPortType() as $portType) { + $portType->toXML($e); + } + + foreach ($this->getBinding() as $binding) { + $binding->toXML($e); + } + + foreach ($this->getService() as $service) { + $service->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractDocumented.php b/src/XML/wsdl/AbstractDocumented.php new file mode 100644 index 0000000..3834eb5 --- /dev/null +++ b/src/XML/wsdl/AbstractDocumented.php @@ -0,0 +1,63 @@ +documentation; + } + */ + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return /*empty($this->documentation)*/ true; + } + + + /** + * Convert this tDocumented to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tDocumented. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + //$this->getDocumentation()?->toXML($e); + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractExtensibilityElement.php b/src/XML/wsdl/AbstractExtensibilityElement.php new file mode 100644 index 0000000..475c78b --- /dev/null +++ b/src/XML/wsdl/AbstractExtensibilityElement.php @@ -0,0 +1,54 @@ +required; + } + + + /** + * Convert this tExtensibilityElement to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tExtensibilityElement + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + + if ($this->getRequired() !== null) { + $e->setAttribute('required', $this->getRequired() ? 'true' : 'false'); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractExtensibleAttributesDocumented.php b/src/XML/wsdl/AbstractExtensibleAttributesDocumented.php new file mode 100644 index 0000000..3fec27a --- /dev/null +++ b/src/XML/wsdl/AbstractExtensibleAttributesDocumented.php @@ -0,0 +1,63 @@ +setAttributesNS($attributes); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return parent::isEmptyElement() && empty($this->getAttributesNS()); + } + + + /** + * Convert this tExtensibleAttributesDocumented to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tExtensibleAttributesDocumented. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + foreach ($this->getAttributesNS() as $attr) { + $attr->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractExtensibleDocumented.php b/src/XML/wsdl/AbstractExtensibleDocumented.php new file mode 100644 index 0000000..69dcf20 --- /dev/null +++ b/src/XML/wsdl/AbstractExtensibleDocumented.php @@ -0,0 +1,62 @@ +setElements($elements); + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + return parent::isEmptyElement() && empty($this->elements); + } + + + /** + * Convert this tExtensibleDocumented to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tExtensibleDocumented. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + foreach ($this->getElements() as $elt) { + $elt->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractFault.php b/src/XML/wsdl/AbstractFault.php new file mode 100644 index 0000000..08a90c4 --- /dev/null +++ b/src/XML/wsdl/AbstractFault.php @@ -0,0 +1,86 @@ +name; + } + + + /** + * Collect the value of the message-property. + * + * @return string + */ + public function getMessage(): string + { + return $this->message; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tParam to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tParam. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + $e->setAttribute('message', $this->getMessage()); + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractImport.php b/src/XML/wsdl/AbstractImport.php new file mode 100644 index 0000000..dfda286 --- /dev/null +++ b/src/XML/wsdl/AbstractImport.php @@ -0,0 +1,86 @@ + $attributes + */ + public function __construct( + protected string $namespace, + protected string $location, + array $attributes = [], + ) { + Assert::validURI($namespace, SchemaViolationException::class); + Assert::validURI($location, SchemaViolationException::class); + + parent::__construct($attributes); + } + + + /** + * Collect the value of the namespace-property. + * + * @return string + */ + public function getNamespace(): string + { + return $this->namespace; + } + + + /** + * Collect the value of the location-property. + * + * @return string + */ + public function getLocation(): string + { + return $this->location; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tImport to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tImport. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('namespace', $this->getNamespace()); + $e->setAttribute('location', $this->getLocation()); + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractMessage.php b/src/XML/wsdl/AbstractMessage.php new file mode 100644 index 0000000..7efd389 --- /dev/null +++ b/src/XML/wsdl/AbstractMessage.php @@ -0,0 +1,98 @@ +getName(); + }, + $parts, + ); + Assert::uniqueValues($partNames, "Part-elements must have unique names.", SchemaViolationException::class); + + parent::__construct($elements); + } + + + /** + * Collect the value of the name-property. + * + * @return string + */ + public function getName(): string + { + return $this->name; + } + + + /** + * Collect the value of the parts-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Part[] + */ + public function getParts(): array + { + return $this->parts; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tParam to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tParam. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + $e->setAttribute('name', $this->getName()); + + foreach ($this->getParts() as $part) { + $part->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractParam.php b/src/XML/wsdl/AbstractParam.php new file mode 100644 index 0000000..3dd63e9 --- /dev/null +++ b/src/XML/wsdl/AbstractParam.php @@ -0,0 +1,89 @@ +name; + } + + + /** + * Collect the value of the message-property. + * + * @return string + */ + public function getMessage(): string + { + return $this->message; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tParam to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tParam. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + if ($this->getName() !== null) { + $e->setAttribute('name', $this->getName()); + } + + $e->setAttribute('message', $this->getMessage()); + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractPart.php b/src/XML/wsdl/AbstractPart.php new file mode 100644 index 0000000..a123f82 --- /dev/null +++ b/src/XML/wsdl/AbstractPart.php @@ -0,0 +1,107 @@ +name; + } + + + /** + * Collect the value of the element-property. + * + * @return string|null + */ + public function getElement(): ?string + { + return $this->element; + } + + + /** + * Collect the value of the type-property. + * + * @return string|null + */ + public function getType(): ?string + { + return $this->type; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tPart to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tPart. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + + if ($this->getElement() !== null) { + $e->setAttribute('element', $this->getElement()); + } + + if ($this->getType() !== null) { + $e->setAttribute('type', $this->getType()); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractPort.php b/src/XML/wsdl/AbstractPort.php new file mode 100644 index 0000000..4d612f9 --- /dev/null +++ b/src/XML/wsdl/AbstractPort.php @@ -0,0 +1,86 @@ +name; + } + + + /** + * Collect the value of the binding-property. + * + * @return string + */ + public function getBinding(): string + { + return $this->binding; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tPort to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tPort. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + $e->setAttribute('binding', $this->getBinding()); + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractPortType.php b/src/XML/wsdl/AbstractPortType.php new file mode 100644 index 0000000..8a95034 --- /dev/null +++ b/src/XML/wsdl/AbstractPortType.php @@ -0,0 +1,89 @@ +name; + } + + + /** + * Collect the value of the operation-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\PortTypeOperation[] + */ + public function getOperation(): array + { + return $this->operation; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tPortType to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tPortType. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + + foreach ($this->getOperation() as $operation) { + $operation->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractPortTypeOperation.php b/src/XML/wsdl/AbstractPortTypeOperation.php new file mode 100644 index 0000000..15242c5 --- /dev/null +++ b/src/XML/wsdl/AbstractPortTypeOperation.php @@ -0,0 +1,132 @@ +name; + } + + + /** + * Collect the value of the parameterOrder-property + * + * @return string|null + */ + public function getParameterOrder(): ?string + { + return $this->parameterOrder; + } + + + /** + * Collect the value of the input-property + * + * @return \SimpleSAML\WSDL\XML\wsdl\AbstractParam|null + */ + public function getInput(): ?AbstractParam + { + return $this->input; + } + + + /** + * Collect the value of the output-property + * + * @return \SimpleSAML\WSDL\XML\wsdl\AbstractParam|null + */ + public function getOutput(): ?AbstractParam + { + return $this->output; + } + + + /** + * Collect the value of the fault-property + * + * @return \SimpleSAML\WSDL\XML\wsdl\Fault[] + */ + public function getFault(): array + { + return $this->fault; + } + + + /** + * Convert this RequestResponseOrOneWayOperation to XML. + * + * @param \DOMElement|null $parent The element we should add this organization to. + * @return \DOMElement This Organization-element. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = $this->instantiateParentElement($parent); + $e->setAttribute('name', $this->getName()); + + if ($this->getParameterOrder() !== null) { + $e->setAttribute('parameterOrder', $this->getParameterOrder()); + } + + $this->getInput()?->toXML($e); + $this->getOutput()?->toXML($e); + + foreach ($this->getFault() as $fault) { + $fault->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractService.php b/src/XML/wsdl/AbstractService.php new file mode 100644 index 0000000..42d1ce2 --- /dev/null +++ b/src/XML/wsdl/AbstractService.php @@ -0,0 +1,99 @@ +getName(); + }, + $ports, + ); + Assert::uniqueValues($portNames, "Port-elements must have unique names.", SchemaViolationException::class); + + parent::__construct($elements); + } + + + /** + * Collect the value of the name-property. + * + * @return string + */ + public function getName(): string + { + return $this->name; + } + + + /** + * Collect the value of the ports-property. + * + * @return \SimpleSAML\WSDL\XML\wsdl\Port[] + */ + public function getPorts(): array + { + return $this->ports; + } + + + /** + * Test if an object, at the state it's in, would produce an empty XML-element + * + * @return bool + */ + public function isEmptyElement(): bool + { + // Upstream abstract elements can be empty, but this one cannot + return false; + } + + + /** + * Convert this tService to XML. + * + * @param \DOMElement|null $parent The element we are converting to XML. + * @return \DOMElement The XML element after adding the data corresponding to this tService. + */ + public function toXML(DOMElement $parent = null): DOMElement + { + $e = parent::toXML($parent); + + $e->setAttribute('name', $this->getName()); + + foreach ($this->getPorts() as $port) { + $port->toXML($e); + } + + return $e; + } +} diff --git a/src/XML/wsdl/AbstractTypes.php b/src/XML/wsdl/AbstractTypes.php new file mode 100644 index 0000000..c0682c0 --- /dev/null +++ b/src/XML/wsdl/AbstractTypes.php @@ -0,0 +1,24 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $operation = BindingOperation::getChildrenOfClass($xml); + + return new static( + self::getAttribute($xml, 'name'), + self::getAttribute($xml, 'type'), + $operation, + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/BindingOperation.php b/src/XML/wsdl/BindingOperation.php new file mode 100644 index 0000000..b68553a --- /dev/null +++ b/src/XML/wsdl/BindingOperation.php @@ -0,0 +1,50 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $input = BindingOperationInput::getChildrenOfClass($xml); + $output = BindingOperationOutput::getChildrenOfClass($xml); + $faults = BindingOperationFault::getChildrenOfClass($xml); + + return new static( + self::getAttribute($xml, 'name'), + array_pop($input), + array_pop($output), + $faults, + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/BindingOperationFault.php b/src/XML/wsdl/BindingOperationFault.php new file mode 100644 index 0000000..9ef6cef --- /dev/null +++ b/src/XML/wsdl/BindingOperationFault.php @@ -0,0 +1,41 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/BindingOperationInput.php b/src/XML/wsdl/BindingOperationInput.php new file mode 100644 index 0000000..2d754bd --- /dev/null +++ b/src/XML/wsdl/BindingOperationInput.php @@ -0,0 +1,41 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalAttribute($xml, 'name', null), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/BindingOperationOutput.php b/src/XML/wsdl/BindingOperationOutput.php new file mode 100644 index 0000000..1b2e16e --- /dev/null +++ b/src/XML/wsdl/BindingOperationOutput.php @@ -0,0 +1,41 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalAttribute($xml, 'name', null), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Definitions.php b/src/XML/wsdl/Definitions.php new file mode 100644 index 0000000..9b30eb9 --- /dev/null +++ b/src/XML/wsdl/Definitions.php @@ -0,0 +1,48 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getOptionalAttribute($xml, 'targetNamespace'), + self::getOptionalAttribute($xml, 'name'), + Import::getChildrenOfClass($xml), + Types::getChildrenOfClass($xml), + Message::getChildrenOfClass($xml), + PortType::getChildrenOfClass($xml), + Binding::getChildrenOfClass($xml), + Service::getChildrenOfClass($xml), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Fault.php b/src/XML/wsdl/Fault.php new file mode 100644 index 0000000..545e488 --- /dev/null +++ b/src/XML/wsdl/Fault.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + self::getAttribute($xml, 'message'), + self::getAttributesNSFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Import.php b/src/XML/wsdl/Import.php new file mode 100644 index 0000000..a561206 --- /dev/null +++ b/src/XML/wsdl/Import.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'namespace'), + self::getAttribute($xml, 'location'), + self::getAttributesNSFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Input.php b/src/XML/wsdl/Input.php new file mode 100644 index 0000000..a0545a7 --- /dev/null +++ b/src/XML/wsdl/Input.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'message'), + self::getOptionalAttribute($xml, 'name'), + self::getAttributesNSFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Message.php b/src/XML/wsdl/Message.php new file mode 100644 index 0000000..f9a468b --- /dev/null +++ b/src/XML/wsdl/Message.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + Part::getChildrenOfClass($xml), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Output.php b/src/XML/wsdl/Output.php new file mode 100644 index 0000000..660f7d6 --- /dev/null +++ b/src/XML/wsdl/Output.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'message'), + self::getOptionalAttribute($xml, 'name'), + self::getAttributesNSFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Part.php b/src/XML/wsdl/Part.php new file mode 100644 index 0000000..0815b40 --- /dev/null +++ b/src/XML/wsdl/Part.php @@ -0,0 +1,43 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + self::getOptionalAttribute($xml, 'element'), + self::getOptionalAttribute($xml, 'type'), + self::getAttributesNSFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Port.php b/src/XML/wsdl/Port.php new file mode 100644 index 0000000..3002723 --- /dev/null +++ b/src/XML/wsdl/Port.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + self::getAttribute($xml, 'binding'), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/PortType.php b/src/XML/wsdl/PortType.php new file mode 100644 index 0000000..669067c --- /dev/null +++ b/src/XML/wsdl/PortType.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + PortTypeOperation::getChildrenOfClass($xml), + self::getAttributesNSFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/PortTypeOperation.php b/src/XML/wsdl/PortTypeOperation.php new file mode 100644 index 0000000..d644898 --- /dev/null +++ b/src/XML/wsdl/PortTypeOperation.php @@ -0,0 +1,80 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + $first = null; + foreach ($xml->childNodes as $element) { + if (!($element instanceof DOMElement)) { + continue; + } elseif ($element->namespaceURI === static::NS) { + if ($element->localName === 'input') { + $first = Input::class; + break; + } elseif ($element->localName === 'output') { + $first = Output::class; + break; + } + } + } + + Assert::notNull($first, SchemaViolationException::class); + + if ($first === Input::class) { + // xs:group solicit-response-or-notification-operation + $input = Input::getChildrenOfClass($xml); + $input = array_pop($input); + Assert::notNull($input, SchemaViolationException::class); + $output = Output::getChildrenOfClass($xml); + $output = array_pop($output); + } else { + // xs:group request-response-or-one-way-operation + // NOTE: input is really output and vice versa!! + $input = Output::getChildrenOfClass($xml); + $input = array_pop($input); + Assert::notNull($input, SchemaViolationException::class); + $output = Input::getChildrenOfClass($xml); + $output = array_pop($output); + } + + return new static( + self::getAttribute($xml, 'name'), + self::getOptionalAttribute($xml, 'parameterOrder'), + $input, + $output, + Fault::getChildrenOfClass($xml), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Service.php b/src/XML/wsdl/Service.php new file mode 100644 index 0000000..2dbfe16 --- /dev/null +++ b/src/XML/wsdl/Service.php @@ -0,0 +1,42 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getAttribute($xml, 'name'), + Port::getChildrenOfClass($xml), + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/src/XML/wsdl/Types.php b/src/XML/wsdl/Types.php new file mode 100644 index 0000000..4d30af3 --- /dev/null +++ b/src/XML/wsdl/Types.php @@ -0,0 +1,40 @@ +localName, static::LOCALNAME, InvalidDOMElementException::class); + Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); + + return new static( + self::getChildElementsFromXML($xml), + ); + } +} diff --git a/tests/WSDL/Constants.php b/tests/WSDL/Constants.php new file mode 100644 index 0000000..34fc899 --- /dev/null +++ b/tests/WSDL/Constants.php @@ -0,0 +1,15 @@ +SomeChunk', + ); + $inputChild = DOMDocumentFactory::fromString( + 'InputChunk', + ); + $outputChild = DOMDocumentFactory::fromString( + 'OutputChunk', + ); + $faultOneChild = DOMDocumentFactory::fromString( + 'FaultOneChunk', + ); + $faultTwoChild = DOMDocumentFactory::fromString( + 'FaultTwoChunk', + ); + + $input = new BindingOperationInput('CustomInputName', [new Chunk($inputChild->documentElement)]); + $output = new BindingOperationOutput('CustomOutputName', [new Chunk($outputChild->documentElement)]); + $faultOne = new BindingOperationFault('CustomFaultOne', [new Chunk($faultOneChild->documentElement)]); + $faultTwo = new BindingOperationFault('CustomFaultTwo', [new Chunk($faultTwoChild->documentElement)]); + + $bindingOperation = new BindingOperation( + 'SomeName', + $input, + $output, + [$faultOne, $faultTwo], + [new Chunk($child->documentElement)], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($bindingOperation), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/BindingTest.php b/tests/WSDL/XML/wsdl/BindingTest.php new file mode 100644 index 0000000..947ff4b --- /dev/null +++ b/tests/WSDL/XML/wsdl/BindingTest.php @@ -0,0 +1,107 @@ +SomeChunk', + ); + $operationChild = DOMDocumentFactory::fromString( + 'OperationChunk', + ); + $inputChild = DOMDocumentFactory::fromString( + 'InputChunk', + ); + $outputChild = DOMDocumentFactory::fromString( + 'OutputChunk', + ); + $faultOneChild = DOMDocumentFactory::fromString( + 'FaultOneChunk', + ); + $faultTwoChild = DOMDocumentFactory::fromString( + 'FaultTwoChunk', + ); + + $input = new BindingOperationInput('CustomInputName', [new Chunk($inputChild->documentElement)]); + $output = new BindingOperationOutput('CustomOutputName', [new Chunk($outputChild->documentElement)]); + $faultOne = new BindingOperationFault('CustomFaultOne', [new Chunk($faultOneChild->documentElement)]); + $faultTwo = new BindingOperationFault('CustomFaultTwo', [new Chunk($faultTwoChild->documentElement)]); + + $operationOne = new BindingOperation( + 'OperationOne', + $input, + $output, + [$faultOne, $faultTwo], + [new Chunk($operationChild->documentElement)], + ); + $operationTwo = new BindingOperation('OperationTwo'); + + $binding = new Binding( + 'MyBinding', + 'ssp:CustomType', + [$operationOne, $operationTwo], + [new Chunk($child->documentElement)], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($binding), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/DefinitionsTest.php b/tests/WSDL/XML/wsdl/DefinitionsTest.php new file mode 100644 index 0000000..02ed638 --- /dev/null +++ b/tests/WSDL/XML/wsdl/DefinitionsTest.php @@ -0,0 +1,192 @@ +TypesChunk', + ); + + $types = new Types([new Chunk($typesChild->documentElement)]); + + // Message + $messageChild = DOMDocumentFactory::fromString( + 'MessageChunk', + ); + + $messageAttr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $messageAttr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr2', 'value2'); + $part1 = new Part('CustomName', 'ssp:CustomElement', 'wsdl:part', [$messageAttr1]); + + $message = new Message('SomeName', [$part1], [new Chunk($messageChild->documentElement)]); + + // PortType + $port = new XMLAttribute(C::NAMESPACE, 'ssp', 'port', '1234'); + $portAttr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $portAttr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr2', 'value2'); + $portAttr3 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr3', 'value3'); + + $input = new Input('ssp:CustomInputMessage', 'CustomInputName', [$portAttr1]); + $output = new Output('ssp:CustomOutputMessage', 'CustomOutputName', [$portAttr2]); + $fault = new Fault('CustomFaultName', 'ssp:CustomFaultMessage', [$portAttr3]); + + $inputOperation = new Operation('Input', '0836217462 0836217463', $input, $output, [$fault]); + + $portType = new PortType('MyPort', [$inputOperation], [$port]); + + // Binding + $bindingChild = DOMDocumentFactory::fromString( + 'BindingChunk', + ); + $operationChild = DOMDocumentFactory::fromString( + 'OperationChunk', + ); + $inputChild = DOMDocumentFactory::fromString( + 'InputChunk', + ); + $outputChild = DOMDocumentFactory::fromString( + 'OutputChunk', + ); + $faultOneChild = DOMDocumentFactory::fromString( + 'FaultOneChunk', + ); + $faultTwoChild = DOMDocumentFactory::fromString( + 'FaultTwoChunk', + ); + + $input = new BindingOperationInput('CustomInputName', [new Chunk($inputChild->documentElement)]); + $output = new BindingOperationOutput('CustomOutputName', [new Chunk($outputChild->documentElement)]); + $faultOne = new BindingOperationFault('CustomFaultOne', [new Chunk($faultOneChild->documentElement)]); + + $operationOne = new BindingOperation( + 'OperationOne', + $input, + $output, + [$faultOne], + [new Chunk($operationChild->documentElement)], + ); + + $binding = new Binding( + 'MyBinding', + 'wsdl:binding', + [$operationOne], + [new Chunk($bindingChild->documentElement)], + ); + + // Service + $serviceChild = DOMDocumentFactory::fromString( + 'ServiceChunk', + ); + $chunkOne = DOMDocumentFactory::fromString( + 'ChunkOne', + ); + $chunkTwo = DOMDocumentFactory::fromString( + 'ChunkTwo', + ); + + $portOne = new Port('PortOne', 'wsdl:binding', [new Chunk($chunkOne->documentElement)]); + + $service = new Service('MyService', [$portOne], [new Chunk($serviceChild->documentElement)]); + + // Child + $child = DOMDocumentFactory::fromString( + 'SomeChunk', + ); + + $definitions = new Definitions( + 'urn:x-simplesamlphp:namespace', + 'MyDefinitions', + [$import], + [$types], + [$message], + [$portType], + [$binding], + [$service], + [new Chunk($child->documentElement)], + ); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($definitions), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/FaultTest.php b/tests/WSDL/XML/wsdl/FaultTest.php new file mode 100644 index 0000000..c6a0161 --- /dev/null +++ b/tests/WSDL/XML/wsdl/FaultTest.php @@ -0,0 +1,65 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($fault), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/ImportTest.php b/tests/WSDL/XML/wsdl/ImportTest.php new file mode 100644 index 0000000..bcdabee --- /dev/null +++ b/tests/WSDL/XML/wsdl/ImportTest.php @@ -0,0 +1,65 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($import), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/InputTest.php b/tests/WSDL/XML/wsdl/InputTest.php new file mode 100644 index 0000000..f2e6865 --- /dev/null +++ b/tests/WSDL/XML/wsdl/InputTest.php @@ -0,0 +1,67 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($input), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/MessageTest.php b/tests/WSDL/XML/wsdl/MessageTest.php new file mode 100644 index 0000000..eace6e7 --- /dev/null +++ b/tests/WSDL/XML/wsdl/MessageTest.php @@ -0,0 +1,89 @@ +SomeChunk', + ); + + $attr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', 'value1'); + $attr2 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr2', 'value2'); + $part1 = new Part('CustomName', 'ssp:CustomElement', 'ssp:CustomType', [$attr1]); + $part2 = new Part('CustomOtherName', 'ssp:CustomElement', 'ssp:CustomType', [$attr2]); + + $message = new Message('SomeName', [$part1, $part2], [new Chunk($child->documentElement)]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($message), + ); + } + + + /** + * Test creating an Message object with multiple parts with the same name fails. + */ + public function testMarshallingMultiplePartsSameName(): void + { + $part1 = new Part('CustomSameName', 'ssp:CustomElement', 'ssp:CustomType'); + $part2 = new Part('CustomSameName', 'ssp:CustomElement', 'ssp:CustomType'); + + $this->expectException(SchemaViolationException::class); + new Message('SomeName', [$part1, $part2]); + } +} diff --git a/tests/WSDL/XML/wsdl/OutputTest.php b/tests/WSDL/XML/wsdl/OutputTest.php new file mode 100644 index 0000000..1dfc665 --- /dev/null +++ b/tests/WSDL/XML/wsdl/OutputTest.php @@ -0,0 +1,67 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($Output), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/PartTest.php b/tests/WSDL/XML/wsdl/PartTest.php new file mode 100644 index 0000000..f6e37d5 --- /dev/null +++ b/tests/WSDL/XML/wsdl/PartTest.php @@ -0,0 +1,65 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($part), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/PortTest.php b/tests/WSDL/XML/wsdl/PortTest.php new file mode 100644 index 0000000..1252c71 --- /dev/null +++ b/tests/WSDL/XML/wsdl/PortTest.php @@ -0,0 +1,66 @@ +SomeChunk', + ); + $port = new Port('CustomName', 'ssp:CustomBinding', [new Chunk($child->documentElement)]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($port), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/PortTypeOperationInputTest.php b/tests/WSDL/XML/wsdl/PortTypeOperationInputTest.php new file mode 100644 index 0000000..7721e64 --- /dev/null +++ b/tests/WSDL/XML/wsdl/PortTypeOperationInputTest.php @@ -0,0 +1,77 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($operation), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/PortTypeOperationOutputTest.php b/tests/WSDL/XML/wsdl/PortTypeOperationOutputTest.php new file mode 100644 index 0000000..a7f9f2d --- /dev/null +++ b/tests/WSDL/XML/wsdl/PortTypeOperationOutputTest.php @@ -0,0 +1,77 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($operation), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/PortTypeTest.php b/tests/WSDL/XML/wsdl/PortTypeTest.php new file mode 100644 index 0000000..7d4822c --- /dev/null +++ b/tests/WSDL/XML/wsdl/PortTypeTest.php @@ -0,0 +1,82 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($portType), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/ServiceTest.php b/tests/WSDL/XML/wsdl/ServiceTest.php new file mode 100644 index 0000000..e0cba9d --- /dev/null +++ b/tests/WSDL/XML/wsdl/ServiceTest.php @@ -0,0 +1,77 @@ +SomeChunk', + ); + $chunkOne = DOMDocumentFactory::fromString( + 'ChunkOne', + ); + $chunkTwo = DOMDocumentFactory::fromString( + 'ChunkTwo', + ); + + $portOne = new Port('PortOne', 'ssp:CustomBinding', [new Chunk($chunkOne->documentElement)]); + $portTwo = new Port('PortTwo', 'ssp:CustomBinding', [new Chunk($chunkTwo->documentElement)]); + + $service = new Service('MyService', [$portOne, $portTwo], [new Chunk($child->documentElement)]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($service), + ); + } +} diff --git a/tests/WSDL/XML/wsdl/TypesTest.php b/tests/WSDL/XML/wsdl/TypesTest.php new file mode 100644 index 0000000..04c5083 --- /dev/null +++ b/tests/WSDL/XML/wsdl/TypesTest.php @@ -0,0 +1,67 @@ +SomeChunk', + ); + + $types = new Types([new Chunk($child->documentElement)]); + + $this->assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($types), + ); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..c66a4c6 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,9 @@ +importFromFile(dirname(__FILE__, 2) . '/src/XML/element.registry.php'); diff --git a/tests/resources/xml/wsdl/Binding.xml b/tests/resources/xml/wsdl/Binding.xml new file mode 100644 index 0000000..c23ad28 --- /dev/null +++ b/tests/resources/xml/wsdl/Binding.xml @@ -0,0 +1,19 @@ + + SomeChunk + + OperationChunk + + InputChunk + + + OutputChunk + + + FaultOneChunk + + + FaultTwoChunk + + + + diff --git a/tests/resources/xml/wsdl/BindingOperation.xml b/tests/resources/xml/wsdl/BindingOperation.xml new file mode 100644 index 0000000..9fe87f5 --- /dev/null +++ b/tests/resources/xml/wsdl/BindingOperation.xml @@ -0,0 +1,15 @@ + + SomeChunk + + InputChunk + + + OutputChunk + + + FaultOneChunk + + + FaultTwoChunk + + diff --git a/tests/resources/xml/wsdl/Definitions.xml b/tests/resources/xml/wsdl/Definitions.xml new file mode 100644 index 0000000..3a997cc --- /dev/null +++ b/tests/resources/xml/wsdl/Definitions.xml @@ -0,0 +1,39 @@ + + SomeChunk + + + TypesChunk + + + MessageChunk + + + + + + + + + + + BindingChunk + + OperationChunk + + InputChunk + + + OutputChunk + + + FaultOneChunk + + + + + ServiceChunk + + ChunkOne + + + diff --git a/tests/resources/xml/wsdl/Fault.xml b/tests/resources/xml/wsdl/Fault.xml new file mode 100644 index 0000000..cbd29c3 --- /dev/null +++ b/tests/resources/xml/wsdl/Fault.xml @@ -0,0 +1 @@ + diff --git a/tests/resources/xml/wsdl/Import.xml b/tests/resources/xml/wsdl/Import.xml new file mode 100644 index 0000000..34c29e1 --- /dev/null +++ b/tests/resources/xml/wsdl/Import.xml @@ -0,0 +1 @@ + diff --git a/tests/resources/xml/wsdl/Input.xml b/tests/resources/xml/wsdl/Input.xml new file mode 100644 index 0000000..8b31f6c --- /dev/null +++ b/tests/resources/xml/wsdl/Input.xml @@ -0,0 +1 @@ + diff --git a/tests/resources/xml/wsdl/Message.xml b/tests/resources/xml/wsdl/Message.xml new file mode 100644 index 0000000..388f296 --- /dev/null +++ b/tests/resources/xml/wsdl/Message.xml @@ -0,0 +1,5 @@ + + SomeChunk + + + diff --git a/tests/resources/xml/wsdl/Output.xml b/tests/resources/xml/wsdl/Output.xml new file mode 100644 index 0000000..57adaa1 --- /dev/null +++ b/tests/resources/xml/wsdl/Output.xml @@ -0,0 +1 @@ + diff --git a/tests/resources/xml/wsdl/Part.xml b/tests/resources/xml/wsdl/Part.xml new file mode 100644 index 0000000..2bc83e3 --- /dev/null +++ b/tests/resources/xml/wsdl/Part.xml @@ -0,0 +1 @@ + diff --git a/tests/resources/xml/wsdl/Port.xml b/tests/resources/xml/wsdl/Port.xml new file mode 100644 index 0000000..bc94f21 --- /dev/null +++ b/tests/resources/xml/wsdl/Port.xml @@ -0,0 +1,3 @@ + + SomeChunk + diff --git a/tests/resources/xml/wsdl/PortType.xml b/tests/resources/xml/wsdl/PortType.xml new file mode 100644 index 0000000..9392e7a --- /dev/null +++ b/tests/resources/xml/wsdl/PortType.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/resources/xml/wsdl/PortTypeOperation_Input.xml b/tests/resources/xml/wsdl/PortTypeOperation_Input.xml new file mode 100644 index 0000000..40e29eb --- /dev/null +++ b/tests/resources/xml/wsdl/PortTypeOperation_Input.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/resources/xml/wsdl/PortTypeOperation_Output.xml b/tests/resources/xml/wsdl/PortTypeOperation_Output.xml new file mode 100644 index 0000000..058211d --- /dev/null +++ b/tests/resources/xml/wsdl/PortTypeOperation_Output.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/resources/xml/wsdl/Service.xml b/tests/resources/xml/wsdl/Service.xml new file mode 100644 index 0000000..09bd004 --- /dev/null +++ b/tests/resources/xml/wsdl/Service.xml @@ -0,0 +1,9 @@ + + SomeChunk + + ChunkOne + + + ChunkTwo + + diff --git a/tests/resources/xml/wsdl/Types.xml b/tests/resources/xml/wsdl/Types.xml new file mode 100644 index 0000000..4497ff2 --- /dev/null +++ b/tests/resources/xml/wsdl/Types.xml @@ -0,0 +1,3 @@ + + SomeChunk + diff --git a/tools/linters/.yaml-lint.yml b/tools/linters/.yaml-lint.yml new file mode 100644 index 0000000..630095a --- /dev/null +++ b/tools/linters/.yaml-lint.yml @@ -0,0 +1,7 @@ +--- + +extends: default + +rules: + line-length: + max: 120