| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * (c) Christian Gripp <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | namespace Core23\SitemapBundle\Tests\DependencyInjection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Core23\SitemapBundle\Action\SitemapXMLAction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Core23\SitemapBundle\Definition\DefintionManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Core23\SitemapBundle\Definition\DefintionManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Core23\SitemapBundle\DependencyInjection\Core23SitemapExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Core23\SitemapBundle\Generator\SitemapGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Core23\SitemapBundle\Generator\SitemapGeneratorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Core23\SitemapBundle\Sitemap\SitemapServiceManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Core23\SitemapBundle\Sitemap\SitemapServiceManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Core23\SitemapBundle\Sitemap\StaticSitemapService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class Core23SitemapExtensionTest extends AbstractExtensionTestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     public function testLoadDefault(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->load(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->assertActions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->assertServices(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertSitemap(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->assertContainerBuilderHasParameter('core23_sitemap.static_urls', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function testLoadWithCacheService(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->load([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'cache' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                 'service' => 'acme.foo.service', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->assertContainerBuilderHasServiceDefinitionWithArgument(SitemapGenerator::class, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function testLoadWithStaticSitemaps(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->load([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             'static' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                 [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                     'url'        => 'http://example.com', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                     'priority'   => 100, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                     'changefreq' => 'daily', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->assertContainerBuilderHasParameter('core23_sitemap.static_urls', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 'url'        => 'http://example.com', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 'priority'   => 100, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                 'changefreq' => 'daily', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     protected function getContainerExtensions(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             new Core23SitemapExtension(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     private function assertActions(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $this->assertContainerBuilderHasService(SitemapXMLAction::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     private function assertServices(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->assertContainerBuilderHasAlias(SitemapServiceManagerInterface::class, SitemapServiceManager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $this->assertContainerBuilderHasAlias(DefintionManagerInterface::class, DefintionManager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->assertContainerBuilderHasAlias(SitemapGeneratorInterface::class, SitemapGenerator::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->assertContainerBuilderHasService(SitemapServiceManager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $this->assertContainerBuilderHasService(DefintionManager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $this->assertContainerBuilderHasService(SitemapGenerator::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |     private function assertSitemap() | 
            
                                                        
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 93 |  |  |         $this->assertContainerBuilderHasService(StaticSitemapService::class); | 
            
                                                        
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 95 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 96 |  |  |  |