<?php
use PHPUnit\Framework\TestCase;
class WsdlTest extends TestCase
{
public function testWsdlMock() : void
{
// http://www.webservicex.com/globalweather.asmx?WSDL
$wsdl = __DIR__ . '/resources/weather.xml';
$mock = $this->getMockFromWsdl($wsdl, 'Webservice');
$result = [
'GetCitiesByCountryResult' => '<NewDataSet>
<Table>
<Country>Italy</Country>
<City>Amendola</City>
</Table>
</NewDataSet>',
];
$mock->expects($this->once())
->method('GetCitiesByCountry')
->will($this->returnValue($result));
self::assertInstanceOf(SoapClient::class, $mock);
self::assertSame($result, $mock->GetCitiesByCountry([
'CountryName' => 'Italy',
]));
}
}