Completed
Push — master ( c2e2b8...acecd3 )
by Meng
03:52
created

SoapClientTest::callAsync()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
use GuzzleHttp\Client;
4
use Meng\AsyncSoap\Guzzle\Factory;
5
use Meng\Soap\HttpBinding\RequestBuilder;
6
7
class SoapClientTest extends PHPUnit_Framework_TestCase
8
{
9
    /** @var  Factory */
10
    private $factory;
11
12
    protected function setUp()
13
    {
14
        $this->factory = new Factory();
15
    }
16
17
    /**
18
     * @test
19
     */
20
    public function call()
21
    {
22
        $client = $this->factory->create(
23
            new Client(),
24
            'http://www.webservicex.net/Statistics.asmx?WSDL',
25
            new RequestBuilder()
26
        );
27
        $response = $client->call('GetStatistics', [['X' => [1,2,3]]]);
28
        $this->assertNotEmpty($response);
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function callAsync()
35
    {
36
        $client = $this->factory->create(
37
            new Client(),
38
            'http://www.webservicex.net/Statistics.asmx?WSDL',
39
            new RequestBuilder()
40
        );
41
        $response = null;
42
        $promise = $client->callAsync('GetStatistics', [['X' => [1,2,3]]])->then(
43
            function ($result) use (&$response) {
44
                $response = $result;
45
            }
46
        );
47
        $promise->wait();
48
        $this->assertNotEmpty($response);
49
    }
50
}