| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File containing the eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\RouterURIRegexTest class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Copyright (C) eZ Systems AS. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license For full copyright and license information view LICENSE file distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use eZ\Publish\Core\MVC\Symfony\SiteAccess; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use eZ\Publish\Core\MVC\Symfony\SiteAccess\Router; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\URI as RegexMatcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Psr\Log\LoggerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class RouterURIRegexTest extends RouterBaseTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 19 |  | View Code Duplication |     public function matchProvider(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             [SimplifiedRequest::fromUrl('http://example.com'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             [SimplifiedRequest::fromUrl('https://example.com'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             [SimplifiedRequest::fromUrl('https://example.com/'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |             [SimplifiedRequest::fromUrl('http://example.com//'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |             [SimplifiedRequest::fromUrl('https://example.com//'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             [SimplifiedRequest::fromUrl('http://example.com:8080/'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/first_siteaccess/'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/?first_siteaccess'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/?first_sa'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/first_salt'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/first_sa.foo'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/test'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/test/foo/'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/first_sa'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/default_sa'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/first_sa'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/first_sa/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             // Double slashes shouldn't be considered as one | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             [SimplifiedRequest::fromUrl('http://example.com//first_sa//'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             [SimplifiedRequest::fromUrl('http://example.com///first_sa///test'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             [SimplifiedRequest::fromUrl('http://example.com//first_sa//foo/bar'), 'default_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/first_sa/foo'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             [SimplifiedRequest::fromUrl('http://example.com:82/first_sa/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             [SimplifiedRequest::fromUrl('http://third_siteaccess/first_sa/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             [SimplifiedRequest::fromUrl('http://first_sa/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             [SimplifiedRequest::fromUrl('https://first_sa/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             [SimplifiedRequest::fromUrl('http://first_sa:81/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:82/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:83/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess/foo/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:82/foo/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:83/foo/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess/foobar/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess//foobar/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess//footestbar/'), 'first_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess/footestbar/'), 'test'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess/footestbar/foobazbar/'), 'test'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:82/footestbar/'), 'test'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:83/footestbar/'), 'test'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/second_sa'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/second_sa/'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/second_sa?param1=foo'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             [SimplifiedRequest::fromUrl('http://example.com/second_sa/foo/'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             [SimplifiedRequest::fromUrl('http://example.com:82/second_sa/'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             [SimplifiedRequest::fromUrl('http://example.com:83/second_sa/'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:82/second_sa/'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             [SimplifiedRequest::fromUrl('http://first_siteaccess:83/second_sa/'), 'second_sa'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function testGetName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $matcher = new RegexMatcher([], []); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $this->assertSame('uri:regexp', $matcher->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 83 |  | View Code Duplication |     public function testSerialize() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $matcher = new RegexMatcher( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                 'regex' => '^/foo(\\w+)bar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                 'itemNumber' => 2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $sa = new SiteAccess('test', 'test', $matcher); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $serializedSA1 = serialize($sa); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar/baz'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $serializedSA2 = serialize($sa); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->assertSame($serializedSA1, $serializedSA2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 101 |  | View Code Duplication |     protected function createRouter(): Router | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |         return new Router( | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |             $this->matcherBuilder, | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |             $this->createMock(LoggerInterface::class), | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |             'default_sa', | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |                 'Regex\\URI' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |                     'regex' => '^/foo(\\w+)bar', | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |                 ], | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |                 'Map\\URI' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |                     'first_sa' => 'first_sa', | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |                     'second_sa' => 'second_sa', | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |                 ], | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |                 'Map\\Host' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |                     'first_sa' => 'first_sa', | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |                     'first_siteaccess' => 'first_sa', | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |                 ], | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |             ], | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |             $this->siteAccessProvider | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\SiteAccessSetting[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 127 |  | View Code Duplication |     public function getSiteAccessProviderSettings(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             new SiteAccessSetting('first_sa', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             new SiteAccessSetting('second_sa', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             new SiteAccessSetting('third_sa', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             new SiteAccessSetting('fourth_sa', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             new SiteAccessSetting('fifth_sa', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             new SiteAccessSetting('test', true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 138 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 139 |  |  |  | 
            
                        
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.