Repository navigation
Expand file tree
/
Copy pathClientTest.php
More file actions
55 lines (42 loc) · 2.16 KB
/
Copy pathClientTest.php
File metadata and controls
55 lines (42 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
use Clue\React\Soap\Client;
use PHPUnit\Framework\TestCase;
use React\Promise\Promise;
use Psr\Http\Message\RequestInterface;
class ClientTest extends TestCase
{
public function testConstructorThrowsWhenUrlIsInvalid()
{
if (extension_loaded('xdebug')) {
$this->markTestSkipped('Invalid WSDL causes a fatal error when ext-xdebug is loaded');
}
$browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
$wsdl = 'invalid';
$client = new Client($browser, $wsdl);
}
public function testNonWsdlClientReturnsSameLocationOptionForAnyFunction()
{
$browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
$client = new Client($browser, null, array('location' => 'http://example.com', 'uri' => 'http://example.com/uri'));
$this->assertEquals('http://example.com', $client->getLocation('anything'));
}
public function testNonWsdlClientReturnsNoTypesAndFunctions()
{
$browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
$client = new Client($browser, null, array('location' => 'http://example.com', 'uri' => 'http://example.com/uri'));
$this->assertNull($client->getTypes());
$this->assertNull($client->getFunctions());
}
public function testNonWsdlClientSendsPostRequestToGivenLocationForAnySoapCall()
{
$verify = function (RequestInterface $request) {
return ($request->getMethod() === 'POST' && (string)$request->getUri() === 'http://example.com');
};
$promise = new Promise(function () { });
$browser = $this->getMockBuilder('Clue\React\Buzz\Browser')->disableOriginalConstructor()->getMock();
$browser->expects($this->once())->method('withOptions')->willReturnSelf();
$browser->expects($this->once())->method('send')->with($this->callback($verify))->willReturn($promise);
$client = new Client($browser, null, array('location' => 'http://example.com', 'uri' => 'http://example.com/uri'));
$client->soapCall('ping', array());
}
}