Completed
Push — master ( 627e2a...ffe287 )
by Meng
02:08
created

FactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 7
dl 0
loc 86
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A nonWsdlMode() 0 6 1
A wsdlMode() 0 70 1
1
<?php
2
3
namespace Meng\AsyncSoap\Guzzle;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Handler\MockHandler;
7
use GuzzleHttp\HandlerStack;
8
use GuzzleHttp\Psr7\Response;
9
use Meng\Soap\HttpBinding\RequestBuilder;
10
11
class FactoryTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @test
15
     */
16
    public function nonWsdlMode()
17
    {
18
        $factory = new Factory();
19
        $client = $factory->create(new Client(), new RequestBuilder(), null, ['uri'=>'', 'location'=>'']);
20
        $this->assertTrue($client instanceof SoapClient);
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function wsdlMode()
27
    {
28
        // this wsdl adapted from https://www.w3.org/2001/04/wsws-proceedings/uche/wsdl.html
29
        $wsdl = <<<EOD
30
<definitions name="EndorsementSearch"
31
  targetNamespace="http://namespaces.snowboard-info.com"
32
  xmlns:es="http://www.snowboard-info.com/EndorsementSearch.wsdl"
33
  xmlns:esxsd="http://schemas.snowboard-info.com/EndorsementSearch.xsd"
34
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
35
  xmlns="http://schemas.xmlsoap.org/wsdl/"
36
>
37
38
  <!-- omitted types section with content model schema info -->
39
40
  <message name="GetEndorsingBoarderRequest">
41
    <part name="body" element="esxsd:GetEndorsingBoarder"/>
42
  </message>
43
44
  <message name="GetEndorsingBoarderResponse">
45
    <part name="body" element="esxsd:GetEndorsingBoarderResponse"/>
46
  </message>
47
48
  <portType name="GetEndorsingBoarderPortType">
49
    <operation name="GetEndorsingBoarder">
50
      <input message="es:GetEndorsingBoarderRequest"/>
51
      <output message="es:GetEndorsingBoarderResponse"/>
52
    </operation>
53
  </portType>
54
55
  <binding name="EndorsementSearchSoapBinding"
56
           type="es:GetEndorsingBoarderPortType">
57
    <soap:binding style="document"
58
                  transport="http://schemas.xmlsoap.org/soap/http"/>
59
    <operation name="GetEndorsingBoarder">
60
      <soap:operation
61
        soapAction="http://www.snowboard-info.com/EndorsementSearch"/>
62
      <input>
63
        <soap:body use="literal"
64
          namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
65
      </input>
66
      <output>
67
        <soap:body use="literal"
68
          namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
69
      </output>
70
      <fault>
71
        <soap:body use="literal"
72
          namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
73
      </fault>
74
    </operation>
75
  </binding>
76
77
  <service name="EndorsementSearchService">
78
    <documentation>snowboarding-info.com Endorsement Service</documentation>
79
    <port name="GetEndorsingBoarderPort"
80
          binding="es:EndorsementSearchSoapBinding">
81
      <soap:address location="http://www.snowboard-info.com/EndorsementSearch"/>
82
    </port>
83
  </service>
84
85
</definitions>
86
EOD;
87
88
        $factory = new Factory();
89
        $handlerMock = new MockHandler([new Response('200', [], $wsdl)]);
90
        $handler = new HandlerStack($handlerMock);
91
        $clientMock = new Client(['handler' => $handler]);
92
        $client = $factory->create($clientMock, new RequestBuilder(), 'wsdl');
93
        $this->assertTrue($client instanceof SoapClient);
94
95
    }
96
}
97