This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
323 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
tests/Generator/3154_namespaced_constant_resolving.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--TEST-- | ||
https://github.com/sebastianbergmann/phpunit-mock-objects/issues/420 | ||
https://github.com/sebastianbergmann/phpunit/issues/3154 | ||
--FILE-- | ||
<?php | ||
namespace Is\Namespaced; | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const A_CONSTANT = 17; | ||
const PHP_VERSION = "0.0.0"; | ||
|
||
class Issue3154 | ||
{ | ||
public function a(int $i = PHP_INT_MAX, int $j = A_CONSTANT, string $v = \PHP_VERSION, string $z = '#'): string | ||
{ | ||
return $z."sum: ".($i+$j).$v; | ||
} | ||
} | ||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$generator = new \PHPUnit\Framework\MockObject\Generator; | ||
|
||
$mock = $generator->generate( | ||
Issue3154::class, | ||
[], | ||
'Issue3154Mock', | ||
true, | ||
true | ||
); | ||
|
||
print $mock['code']; | ||
--EXPECT-- | ||
class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework\MockObject\MockObject | ||
{ | ||
private $__phpunit_invocationMocker; | ||
private $__phpunit_originalObject; | ||
private $__phpunit_configurable = ['a']; | ||
|
||
public function __clone() | ||
{ | ||
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker(); | ||
} | ||
|
||
public function a(int $i = PHP_INT_MAX, int $j = Is\Namespaced\A_CONSTANT, string $v = PHP_VERSION, string $z = '#'): string | ||
{ | ||
$arguments = array($i, $j, $v, $z); | ||
$count = func_num_args(); | ||
|
||
if ($count > 4) { | ||
$_arguments = func_get_args(); | ||
|
||
for ($i = 4; $i < $count; $i++) { | ||
$arguments[] = $_arguments[$i]; | ||
} | ||
} | ||
|
||
$result = $this->__phpunit_getInvocationMocker()->invoke( | ||
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation( | ||
'Is\Namespaced\Issue3154', 'a', $arguments, 'string', $this, true | ||
) | ||
); | ||
|
||
return $result; | ||
} | ||
|
||
public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher) | ||
{ | ||
return $this->__phpunit_getInvocationMocker()->expects($matcher); | ||
} | ||
|
||
public function method() | ||
{ | ||
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount; | ||
$expects = $this->expects($any); | ||
return call_user_func_array(array($expects, 'method'), func_get_args()); | ||
} | ||
|
||
public function __phpunit_setOriginalObject($originalObject) | ||
{ | ||
$this->__phpunit_originalObject = $originalObject; | ||
} | ||
|
||
public function __phpunit_getInvocationMocker() | ||
{ | ||
if ($this->__phpunit_invocationMocker === null) { | ||
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable); | ||
} | ||
|
||
return $this->__phpunit_invocationMocker; | ||
} | ||
|
||
public function __phpunit_hasMatchers() | ||
{ | ||
return $this->__phpunit_getInvocationMocker()->hasMatchers(); | ||
} | ||
|
||
public function __phpunit_verify($unsetInvocationMocker = true) | ||
{ | ||
$this->__phpunit_getInvocationMocker()->verify(); | ||
|
||
if ($unsetInvocationMocker) { | ||
$this->__phpunit_invocationMocker = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?xml version="1.0"?> | ||
|
||
<!-- WSDL description of the Google Web APIs. | ||
The Google Web APIs are in beta release. All interfaces are subject to | ||
change as we refine and extend our APIs. Please see the terms of use | ||
for more information. --> | ||
|
||
<!-- Revision 2002-08-16 --> | ||
|
||
<definitions name="GoogleSearch" | ||
targetNamespace="urn:GoogleSearch" | ||
xmlns:typens="urn:GoogleSearch" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" | ||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/"> | ||
|
||
<!-- Types for search - result elements, directory categories --> | ||
|
||
<types> | ||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" | ||
targetNamespace="urn:GoogleSearch"> | ||
|
||
<xsd:complexType name="GoogleSearchResult"> | ||
<xsd:all> | ||
<xsd:element name="documentFiltering" type="xsd:boolean"/> | ||
<xsd:element name="searchComments" type="xsd:string"/> | ||
<xsd:element name="estimatedTotalResultsCount" type="xsd:int"/> | ||
<xsd:element name="estimateIsExact" type="xsd:boolean"/> | ||
<xsd:element name="resultElements" type="typens:ResultElementArray"/> | ||
<xsd:element name="searchQuery" type="xsd:string"/> | ||
<xsd:element name="startIndex" type="xsd:int"/> | ||
<xsd:element name="endIndex" type="xsd:int"/> | ||
<xsd:element name="searchTips" type="xsd:string"/> | ||
<xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/> | ||
<xsd:element name="searchTime" type="xsd:double"/> | ||
</xsd:all> | ||
</xsd:complexType> | ||
|
||
<xsd:complexType name="ResultElement"> | ||
<xsd:all> | ||
<xsd:element name="summary" type="xsd:string"/> | ||
<xsd:element name="URL" type="xsd:string"/> | ||
<xsd:element name="snippet" type="xsd:string"/> | ||
<xsd:element name="title" type="xsd:string"/> | ||
<xsd:element name="cachedSize" type="xsd:string"/> | ||
<xsd:element name="relatedInformationPresent" type="xsd:boolean"/> | ||
<xsd:element name="hostName" type="xsd:string"/> | ||
<xsd:element name="directoryCategory" type="typens:DirectoryCategory"/> | ||
<xsd:element name="directoryTitle" type="xsd:string"/> | ||
</xsd:all> | ||
</xsd:complexType> | ||
|
||
<xsd:complexType name="ResultElementArray"> | ||
<xsd:complexContent> | ||
<xsd:restriction base="soapenc:Array"> | ||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/> | ||
</xsd:restriction> | ||
</xsd:complexContent> | ||
</xsd:complexType> | ||
|
||
<xsd:complexType name="DirectoryCategoryArray"> | ||
<xsd:complexContent> | ||
<xsd:restriction base="soapenc:Array"> | ||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/> | ||
</xsd:restriction> | ||
</xsd:complexContent> | ||
</xsd:complexType> | ||
|
||
<xsd:complexType name="DirectoryCategory"> | ||
<xsd:all> | ||
<xsd:element name="fullViewableName" type="xsd:string"/> | ||
<xsd:element name="specialEncoding" type="xsd:string"/> | ||
</xsd:all> | ||
</xsd:complexType> | ||
|
||
</xsd:schema> | ||
</types> | ||
|
||
<!-- Messages for Google Web APIs - cached page, search, spelling. --> | ||
|
||
<message name="doGetCachedPage"> | ||
<part name="key" type="xsd:string"/> | ||
<part name="url" type="xsd:string"/> | ||
</message> | ||
|
||
<message name="doGetCachedPageResponse"> | ||
<part name="return" type="xsd:base64Binary"/> | ||
</message> | ||
|
||
<message name="doSpellingSuggestion"> | ||
<part name="key" type="xsd:string"/> | ||
<part name="phrase" type="xsd:string"/> | ||
</message> | ||
|
||
<message name="doSpellingSuggestionResponse"> | ||
<part name="return" type="xsd:string"/> | ||
</message> | ||
|
||
<!-- note, ie and oe are ignored by server; all traffic is UTF-8. --> | ||
|
||
<message name="doGoogleSearch"> | ||
<part name="key" type="xsd:string"/> | ||
<part name="q" type="xsd:string"/> | ||
<part name="start" type="xsd:int"/> | ||
<part name="maxResults" type="xsd:int"/> | ||
<part name="filter" type="xsd:boolean"/> | ||
<part name="restrict" type="xsd:string"/> | ||
<part name="safeSearch" type="xsd:boolean"/> | ||
<part name="lr" type="xsd:string"/> | ||
<part name="ie" type="xsd:string"/> | ||
<part name="oe" type="xsd:string"/> | ||
</message> | ||
|
||
<message name="doGoogleSearchResponse"> | ||
<part name="return" type="typens:GoogleSearchResult"/> | ||
</message> | ||
|
||
<!-- Port for Google Web APIs, "GoogleSearch" --> | ||
|
||
<portType name="GoogleSearchPort"> | ||
|
||
<operation name="doGetCachedPage"> | ||
<input message="typens:doGetCachedPage"/> | ||
<output message="typens:doGetCachedPageResponse"/> | ||
</operation> | ||
|
||
<operation name="doSpellingSuggestion"> | ||
<input message="typens:doSpellingSuggestion"/> | ||
<output message="typens:doSpellingSuggestionResponse"/> | ||
</operation> | ||
|
||
<operation name="doGoogleSearch"> | ||
<input message="typens:doGoogleSearch"/> | ||
<output message="typens:doGoogleSearchResponse"/> | ||
</operation> | ||
|
||
</portType> | ||
|
||
|
||
<!-- Binding for Google Web APIs - RPC, SOAP over HTTP --> | ||
|
||
<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort"> | ||
<soap:binding style="rpc" | ||
transport="http://schemas.xmlsoap.org/soap/http"/> | ||
|
||
<operation name="doGetCachedPage"> | ||
<soap:operation soapAction="urn:GoogleSearchAction"/> | ||
<input> | ||
<soap:body use="encoded" | ||
namespace="urn:GoogleSearch" | ||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" | ||
namespace="urn:GoogleSearch" | ||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
|
||
<operation name="doSpellingSuggestion"> | ||
<soap:operation soapAction="urn:GoogleSearchAction"/> | ||
<input> | ||
<soap:body use="encoded" | ||
namespace="urn:GoogleSearch" | ||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" | ||
namespace="urn:GoogleSearch" | ||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
|
||
<operation name="doGoogleSearch"> | ||
<soap:operation soapAction="urn:GoogleSearchAction"/> | ||
<input> | ||
<soap:body use="encoded" | ||
namespace="urn:GoogleSearch" | ||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" | ||
namespace="urn:GoogleSearch" | ||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
</binding> | ||
|
||
<!-- Endpoint for Google Web APIs --> | ||
<service name="GoogleSearchService"> | ||
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding"> | ||
<soap:address location="http://api.google.com/search/beta2"/> | ||
</port> | ||
</service> | ||
|
||
</definitions> |