-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from veewee/object-null-values
Accept nillable values in object encoder
- Loading branch information
Showing
6 changed files
with
170 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\Encoding\Test\PhpCompatibility\Implied; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use Soap\Encoding\Decoder; | ||
use Soap\Encoding\Driver; | ||
use Soap\Encoding\Encoder; | ||
use Soap\Encoding\Test\PhpCompatibility\AbstractCompatibilityTests; | ||
|
||
#[CoversClass(Driver::class)] | ||
#[CoversClass(Encoder::class)] | ||
#[CoversClass(Decoder::class)] | ||
final class ImpliedSchema001Test extends AbstractCompatibilityTests | ||
{ | ||
protected string $schema = <<<EOXML | ||
<element name="testType"> | ||
<complexType> | ||
<sequence> | ||
<element name="customerId" type="xsd:string" /> | ||
<element name="countryCode" type="xsd:string" nillable="true" /> | ||
</sequence> | ||
</complexType> | ||
</element> | ||
EOXML; | ||
protected string $type = 'type="tns:testType"'; | ||
|
||
protected function calculateParam(): mixed | ||
{ | ||
return (object)[ | ||
'customerId' => '123', | ||
'countryCode' => null, | ||
]; | ||
} | ||
|
||
protected function expectXml(): string | ||
{ | ||
return <<<XML | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://test-uri/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> | ||
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | ||
<tns:test> | ||
<testParam xsi:type="tns:testType"> | ||
<customerId xsi:type="xsd:string">123</customerId> | ||
<countryCode xsi:nil="true" /> | ||
</testParam> | ||
</tns:test> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope> | ||
XML; | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\Encoding\Test\PhpCompatibility\Implied; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use Soap\Encoding\Decoder; | ||
use Soap\Encoding\Driver; | ||
use Soap\Encoding\Encoder; | ||
use Soap\Encoding\Test\PhpCompatibility\AbstractCompatibilityTests; | ||
|
||
#[CoversClass(Driver::class)] | ||
#[CoversClass(Encoder::class)] | ||
#[CoversClass(Decoder::class)] | ||
final class ImpliedSchema002Test extends AbstractCompatibilityTests | ||
{ | ||
protected string $schema = <<<EOXML | ||
<element name="testType"> | ||
<complexType> | ||
<sequence> | ||
<element name="customerId" type="xsd:string" /> | ||
<element name="countryCode" type="xsd:string" nillable="true" /> | ||
</sequence> | ||
</complexType> | ||
</element> | ||
EOXML; | ||
protected string $type = 'type="tns:testType"'; | ||
|
||
protected function calculateParam(): mixed | ||
{ | ||
return (object)[ | ||
'customerId' => '123', | ||
'countryCode' => 'BE', | ||
]; | ||
} | ||
|
||
protected function expectXml(): string | ||
{ | ||
return <<<XML | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://test-uri/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> | ||
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | ||
<tns:test> | ||
<testParam xsi:type="tns:testType"> | ||
<customerId xsi:type="xsd:string">123</customerId> | ||
<countryCode xsi:type="xsd:string">BE</countryCode> | ||
</testParam> | ||
</tns:test> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope> | ||
XML; | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\Encoding\Test\PhpCompatibility\Implied; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use Soap\Encoding\Decoder; | ||
use Soap\Encoding\Driver; | ||
use Soap\Encoding\Encoder; | ||
use Soap\Encoding\Test\PhpCompatibility\AbstractCompatibilityTests; | ||
|
||
#[CoversClass(Driver::class)] | ||
#[CoversClass(Encoder::class)] | ||
#[CoversClass(Decoder::class)] | ||
final class ImpliedSchema003Test extends AbstractCompatibilityTests | ||
{ | ||
protected string $schema = <<<EOXML | ||
<element name="testType"> | ||
<complexType> | ||
<sequence> | ||
<element name="customerId" type="xsd:string" /> | ||
<element name="countryCode" type="xsd:string" minOccurs="0" maxOccurs="1" /> | ||
</sequence> | ||
</complexType> | ||
</element> | ||
EOXML; | ||
protected string $type = 'type="tns:testType"'; | ||
|
||
protected function calculateParam(): mixed | ||
{ | ||
return (object)[ | ||
'customerId' => '123', | ||
'countryCode' => null, | ||
]; | ||
} | ||
|
||
protected function expectXml(): string | ||
{ | ||
return <<<XML | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://test-uri/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> | ||
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> | ||
<tns:test> | ||
<testParam xsi:type="tns:testType"> | ||
<customerId xsi:type="xsd:string">123</customerId> | ||
</testParam> | ||
</tns:test> | ||
</SOAP-ENV:Body> | ||
</SOAP-ENV:Envelope> | ||
XML; | ||
} | ||
} |
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