| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the Sylius package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Paweł Jędrzejewski | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace spec\Sylius\Bundle\UiBundle\Renderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PhpSpec\ObjectBehavior; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sylius\Bundle\UiBundle\Registry\TemplateBlock; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Twig\Environment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | final class TwigTemplateBlockRendererSpec extends ObjectBehavior | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     function let(Environment $twig): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->beConstructedWith($twig); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     function it_is_a_template_block_renderer(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->shouldImplement(TemplateBlockRendererInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     function it_renders_a_template_block(Environment $twig): void | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         $twig->render('block.txt.twig', ['foo' => 'bar', '_event' => 'event_name'])->willReturn('Block content'); | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         $this->render( | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |             'event_name', | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |             new TemplateBlock('block_name', 'block.txt.twig', [], 0, true), | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             ['foo' => 'bar'] | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         )->shouldReturn('Block content'); | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     function it_merges_template_block_context_with_passed_context(Environment $twig): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $twig->render('block.txt.twig', ['sample' => 'Hello', 'switch' => true, '_event' => 'event_name'])->willReturn('Block content'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->render( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             'event_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             new TemplateBlock('block_name', 'block.txt.twig', ['sample' => 'Hi', 'switch' => true], 0, true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             ['sample' => 'Hello'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         )->shouldReturn('Block content'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 54 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |  |