Skip to content

Commit

Permalink
Merge branch '8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 17, 2019
2 parents 10d79b5 + 018596e commit 36057af
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
1 change: 1 addition & 0 deletions ChangeLog-7.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes of the PHPUnit 7.5 release series are documented in this fil

### Fixed

* Fixed [#3530](https://github.com/sebastianbergmann/phpunit/issues/3530): `generateClassFromWsdl()` does not handle methods with multiple output values
* Fixed [#3531](https://github.com/sebastianbergmann/phpunit/issues/3531): Test suite fails on warning
* Fixed [#3534](https://github.com/sebastianbergmann/phpunit/pull/3534): Wrong message in `ConstraintTestCase`

Expand Down
1 change: 1 addition & 0 deletions ChangeLog-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes of the PHPUnit 8.0 release series are documented in this fil

## [8.0.4] - 2019-MM-DD

* Fixed [#3530](https://github.com/sebastianbergmann/phpunit/issues/3530): `generateClassFromWsdl()` does not handle methods with multiple output values
* Fixed [#3531](https://github.com/sebastianbergmann/phpunit/issues/3531): Test suite fails on warning
* Fixed [#3534](https://github.com/sebastianbergmann/phpunit/pull/3534): Wrong message in `ConstraintTestCase`

Expand Down
16 changes: 7 additions & 9 deletions src/Framework/MockObject/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,16 @@ public function generateClassFromWsdl($wsdlFile, $className, array $methods = []
$methodsBuffer = '';

foreach ($_methods as $method) {
$nameStart = \strpos($method, ' ') + 1;
$nameEnd = \strpos($method, '(');
$name = \substr($method, $nameStart, $nameEnd - $nameStart);
\preg_match_all('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\(/', $method, $matches, \PREG_OFFSET_CAPTURE);
$lastFunction = \array_pop($matches[0]);
$nameStart = $lastFunction[1];
$nameEnd = $nameStart + \strlen($lastFunction[0]) - 1;
$name = \str_replace('(', '', $lastFunction[0]);

if (empty($methods) || \in_array($name, $methods, true)) {
$args = \explode(
$args = \explode(
',',
\substr(
$method,
$nameEnd + 1,
\strpos($method, ')') - $nameEnd - 1
)
\str_replace(')', '', \substr($method, $nameEnd + 1))
);

foreach (\range(0, \count($args) - 1) as $i) {
Expand Down
33 changes: 33 additions & 0 deletions tests/_files/3530.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://some-web-service.com/CustomUI" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsdLocal0="http://www.some-web-service.com/xml/ContactInformation" targetNamespace="http://some-web-service.com/CustomUI">
<message name="Contact_Information_Input">
<part name="Contact_Id" type="xsd:string" />
</message>
<message name="Contact_Information_Output">
<part name="Response_Code" type="xsd:string" />
<part name="Response_Message" type="xsd:string" />
</message>
<portType name="Contact_Information">
<operation name="Contact_Information">
<input message="tns:Contact_Information_Input" />
<output message="tns:Contact_Information_Output" />
</operation>
</portType>
<binding name="Contact_Information" type="tns:Contact_Information">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<operation name="Contact_Information">
<soap:operation soapAction="rpc/http://some-web-service.com/CustomUI:Contact_Information" />
<input>
<soap:body namespace="http://some-web-service.com/CustomUI" use="literal" />
</input>
<output>
<soap:body namespace="http://some-web-service.com/CustomUI" use="literal" />
</output>
</operation>
</binding>
<service name="Web_Service">
<port binding="tns:Contact_Information" name="Contact_Information">
<soap:address location="https://some-web-service.com" />
</port>
</service>
</definitions>
27 changes: 27 additions & 0 deletions tests/end-to-end/mock-objects/generator/3530.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
\PHPUnit\Framework\MockObject\Generator::generateClassFromWsdl('3530.wsdl', 'Test')
--SKIPIF--
<?php declare(strict_types=1);
if (!extension_loaded('soap')) echo 'skip: SOAP extension is required';
--FILE--
<?php declare(strict_types=1);
require __DIR__ . '/../../../../vendor/autoload.php';

$generator = new \PHPUnit\Framework\MockObject\Generator;

print $generator->generateClassFromWsdl(
__DIR__ . '/../../../_files/3530.wsdl',
'Test'
);
--EXPECTF--
class Test extends \SoapClient
{
public function __construct($wsdl, array $options)
{
parent::__construct('%s/3530.wsdl', $options);
}

public function Contact_Information($Contact_Id)
{
}
}

0 comments on commit 36057af

Please sign in to comment.