| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Copyright (C) 2013-2020 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Piotr Olaszewski <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * in the Software without restriction, including without limitation the rights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * furnished to do so, subject to the following conditions: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * The above copyright notice and this permission notice shall be included in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * all copies or substantial portions of the Software. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * SOFTWARE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | namespace Tests\WSDL\Builder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Ouzo\Tests\CatchException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use WSDL\Builder\WSDLBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * WSDLBuilderTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * @author Piotr Olaszewski <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | class WSDLBuilderTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     public function shouldThrowExceptionWhenNameIsEmpty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         CatchException::when($WSDLBuilder)->setName(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             ->hasMessage('Name cannot be empty'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function shouldThrowExceptionWhenTargetNamespaceIsEmpty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         CatchException::when($WSDLBuilder)->setTargetNamespace(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             ->hasMessage('Target namespace cannot be empty'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public function shouldThrowExceptionWhenNSIsEmpty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         CatchException::when($WSDLBuilder)->setNs(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             ->hasMessage('NS cannot be empty'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function shouldThrowExceptionWhenLocationIsEmpty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         CatchException::when($WSDLBuilder)->setLocation(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             ->hasMessage('Location cannot be empty'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     public function shouldThrowExceptionWhenStyleIsInValid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         CatchException::when($WSDLBuilder)->setStyle('INVALID'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             ->hasMessage('Invalid style [INVALID] available styles: [RPC, DOCUMENT]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     public function shouldThrowExceptionWhenUseIsInValid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         CatchException::when($WSDLBuilder)->setUse('INVALID'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             ->hasMessage('Invalid use [INVALID] available uses: [LITERAL, ENCODED]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function shouldThrowExceptionWhenBindingTypeIsInValid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         //given | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         CatchException::when($WSDLBuilder)->setSoapVersion('INVALID'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         CatchException::assertThat() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             ->hasMessage('Invalid binding type [INVALID] available types: [SOAP_11, SOAP_12]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * @test | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 152 |  |  |     public function shouldThrowExceptionWhenParameterStyleIsInValid() | 
            
                                                        
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 154 |  |  |         //given | 
            
                                                        
            
                                    
            
            
                | 155 |  |  |         $WSDLBuilder = WSDLBuilder::instance(); | 
            
                                                        
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 157 |  |  |         //when | 
            
                                                        
            
                                    
            
            
                | 158 |  |  |         CatchException::when($WSDLBuilder)->setParameterStyle('INVALID'); | 
            
                                                        
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 160 |  |  |         //then | 
            
                                                        
            
                                    
            
            
                | 161 |  |  |         CatchException::assertThat() | 
            
                                                        
            
                                    
            
            
                | 162 |  |  |             ->hasMessage('Invalid parameter style [INVALID] available parameter styles: [BARE, WRAPPED]'); | 
            
                                                        
            
                                    
            
            
                | 163 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 164 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 165 |  |  |  |