| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file is part of the Sonata Project package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * (c) Thomas Rabaix <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace Sonata\AdminBundle\Tests\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sonata\AdminBundle\Command\Validators; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @author Andrej Hudec <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | class ValidatorsTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @dataProvider getValidateUsernameTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     public function testValidateUsername(string $expected, string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->assertSame($expected, Validators::validateUsername($value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function getValidateUsernameTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             ['Foo', 'Foo'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             ['abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789', 'abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     public function testValidateUsernameWithException(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->expectException(\InvalidArgumentException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         Validators::validateUsername(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @dataProvider getValidateEntityNameTests | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     public function testValidateEntityName(array $expected, string $value): void | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         $this->assertSame($expected, Validators::validateEntityName($value)); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     public function getValidateEntityNameTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             [['AcmeBlogBundle', 'Post'], 'AcmeBlogBundle:Post'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             [['Foo\Bar\BlogBundle', 'Post'], 'Foo/Bar/BlogBundle:Post'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             [['Foo\Bar\BlogBundle', 'Post'], 'Foo\Bar\BlogBundle:Post'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @dataProvider getValidateEntityNamesWithExceptionTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function testValidateEntityNameWithException(string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->expectException(\InvalidArgumentException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         Validators::validateEntityName($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public function getValidateEntityNamesWithExceptionTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             ['Sonata\AdminBundle\Admin\AbstractAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ['Sonata/AdminBundle/Admin/Admin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             ['Foo/Bar/Controller'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             ['Foo/BarController'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             ['Foo_Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             ['FooBarController'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             ['FooBarAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @dataProvider getValidateClassTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     public function testValidateClass(string $expected, string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->assertSame($expected, Validators::validateClass($value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     public function getValidateClassTests() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             ['Sonata\AdminBundle\Admin\AbstractAdmin', 'Sonata\AdminBundle\Admin\AbstractAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             ['Sonata\AdminBundle\Admin\AbstractAdmin', 'Sonata/AdminBundle/Admin/AbstractAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @dataProvider getValidateClassWithExceptionTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     public function testValidateClassWithException(string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->expectException(\InvalidArgumentException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         Validators::validateClass($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     public function getValidateClassWithExceptionTests() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             ['Foo:BarAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             ['Foo:Bar:Admin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             ['Foo/Bar/Admin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      * @dataProvider getValidateAdminClassBasenameTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     public function testValidateAdminClassBasename(string $expected, string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->assertSame($expected, Validators::validateAdminClassBasename($value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     public function getValidateAdminClassBasenameTests() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             ['FooBarAdmin', 'FooBarAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             ['Foo\Foo\BarAdmin', 'Foo\Foo\BarAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             ['Foo\Foo\BarAdmin', 'Foo/Foo/BarAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * @dataProvider getValidateAdminClassBasenameWithExceptionTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     public function testValidateAdminClassBasenameWithException(string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $this->expectException(\InvalidArgumentException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         Validators::validateAdminClassBasename($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     public function getValidateAdminClassBasenameWithExceptionTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             ['Foo:BarAdmin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             ['Foo:Bar:Admin'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             ['*+-!:@&^%'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @dataProvider getValidateControllerClassBasenameTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     public function testValidateControllerClassBasename(string $expected, string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         $this->assertSame($expected, Validators::validateControllerClassBasename($value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     public function getValidateControllerClassBasenameTests() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             ['FooBarController', 'FooBarController'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             ['Foo\Foo\BarController', 'Foo/Foo/BarController'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             ['Foo\Foo\BarController', 'Foo\Foo\BarController'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * @dataProvider getValidateControllerClassBasenameWithExceptionTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     public function testValidateControllerClassBasenameWithException(string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $this->expectException(\InvalidArgumentException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         Validators::validateControllerClassBasename($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     public function getValidateControllerClassBasenameWithExceptionTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             [' foobar '], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             [' FooBar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             ['Foo Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             ['Foo-Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             ['foo*'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             ['foo+'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             ['foo-'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             ['foo!'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             ['foo@'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             ['foo&'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             ['foo%'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             ['foo^'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             ['foo(bar)'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             ['foo[bar]'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             ['foo{bar}'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             ['Foo/Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |             ['Foo\Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |             ['Foo/BarControllr'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             ['Foo\BarControllr'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             ['Foo:BarControllr'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @dataProvider getValidateServicesFileTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     public function testValidateServicesFile(string $expected, string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $this->assertSame($expected, Validators::validateServicesFile($value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     public function getValidateServicesFileTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             ['foobar', 'foobar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             ['fooBar', 'fooBar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             [' foo Bar ', ' foo Bar '], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             ['Foo/Bar', '/Foo/Bar/'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             ['Foo/BAR', '/Foo/BAR/'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             ['Foo/Bar', '/Foo/Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             ['Foo/Bar', 'Foo/Bar/'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      * @dataProvider getValidateServiceIdTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     public function testValidateServiceId(string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         $this->assertSame($value, Validators::validateServiceId($value)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     public function getValidateServiceIdTests(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             ['abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             ['Foo_Bar_0123'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             ['Foo.Bar.0123'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      * @dataProvider getValidateServiceIdWithExceptionTests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     public function testValidateServiceIdWithException(string $value): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         $this->expectException(\InvalidArgumentException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         Validators::validateServiceId($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |     public function getValidateServiceIdWithExceptionTests(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |             [' foobar '], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             [' FooBar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             ['Foo Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             ['Foo-Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             ['foo*'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             ['foo+'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             ['foo-'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |             ['foo!'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |             ['foo@'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |             ['foo&'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             ['foo%'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             ['foo^'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             ['foo:'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             ['foo(bar)'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             ['foo[bar]'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             ['foo{bar}'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             ['Foo/Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             ['Foo\Bar'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 282 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 283 |  |  |  |