| 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 InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use WSDL\Annotation\BindingType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use WSDL\Annotation\SoapBinding; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use WSDL\Builder\IsValid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * IsValidTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * @author Piotr Olaszewski <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | class IsValidTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @dataProvider validStyles | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param string $style | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public function shouldNotThrowExceptionWhenStyleIsValid($style) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         IsValid::style($style); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         //then no exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $this->assertTrue(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function validStyles() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             [SoapBinding::RPC], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             [SoapBinding::DOCUMENT] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function shouldThrowExceptionWhenStyleIsInValid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             IsValid::style('INVALID_STYLE'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             $this->assertEquals('Invalid style [INVALID_STYLE] available styles: [RPC, DOCUMENT]', $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @dataProvider validUses | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * @param string $use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     public function shouldNotThrowExceptionWhenUseIsValid($use) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         IsValid::useStyle($use); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         //then no exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $this->assertTrue(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     public function validUses() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             [SoapBinding::LITERAL], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             [SoapBinding::ENCODED] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     public function shouldThrowExceptionWhenUseIsInValid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             IsValid::useStyle('INVALID_USE'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             $this->assertEquals('Invalid use [INVALID_USE] available uses: [LITERAL, ENCODED]', $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * @dataProvider validSoapVersions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @param string $soapVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     public function shouldNotThrowExceptionWhenSoapVersionIsValid($soapVersion) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         IsValid::soapVersion($soapVersion); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         //then no exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $this->assertTrue(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     public function validSoapVersions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             [BindingType::SOAP_11], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             [BindingType::SOAP_12] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     public function shouldThrowExceptionWhenSoapVersionIsInValid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             IsValid::soapVersion('INVALID_SOAP_VERSION'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             $this->assertEquals('Invalid binding type [INVALID_SOAP_VERSION] available types: [SOAP_11, SOAP_12]', $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     public function shouldNotThrowExceptionWhenValueIsNotEmpty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         IsValid::notEmpty('some value'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         //then no exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $this->assertTrue(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      * @dataProvider emptyValues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * @param mixed $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 170 |  | View Code Duplication |     public function shouldThrowExceptionWhenValueIsEmpty($value) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |             IsValid::notEmpty($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             $this->assertEquals('Value cannot be empty', $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      * @dataProvider emptyValues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * @param mixed $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * @param string $customMessage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 189 |  | View Code Duplication |     public function shouldThrowExceptionWithCustomMessageWhenValueIsEmpty($value, $customMessage) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             IsValid::notEmpty($value, $customMessage); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             $this->assertEquals($customMessage, $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     public function emptyValues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |             ['', 'First empty value'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             [null, 'Second empty value'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @dataProvider validParameterStyles | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * @param string $parameterStyle | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 214 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  |     public function shouldNotThrowExceptionWhenParameterStyleIsValid($parameterStyle) | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  |         //when | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  |         IsValid::parameterStyle($parameterStyle, SoapBinding::DOCUMENT); | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  |         //then no exception | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  |         $this->assertTrue(true); | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     public function validParameterStyles() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             [SoapBinding::BARE], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             [SoapBinding::WRAPPED] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 235 |  | View Code Duplication |     public function shouldThrowExceptionWhenParameterStyleIsInValid() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             IsValid::parameterStyle('INVALID_PARAMETER_STYLE', SoapBinding::RPC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             $this->assertEquals('Invalid parameter style [INVALID_PARAMETER_STYLE] available parameter styles: [BARE, WRAPPED]', $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 251 |  | View Code Duplication |     public function shouldThrowExceptionWhenSetParameterStyleWrappedForRpc() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         //when | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             IsValid::parameterStyle(SoapBinding::WRAPPED, SoapBinding::RPC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             $this->assertFalse(true, 'Triggered when exception is not throw'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         } catch (InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |             //then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |             $this->assertEquals('For RPC style parameters cannot be wrapped', $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             $this->assertInstanceOf('\InvalidArgumentException', $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 263 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 264 |  |  |  | 
            
                        
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.