| 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\MailerBundle\Renderer\Adapter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PhpSpec\ObjectBehavior; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Prophecy\Argument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sylius\Component\Mailer\Event\EmailRenderEvent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sylius\Component\Mailer\Model\EmailInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Sylius\Component\Mailer\Renderer\Adapter\AbstractAdapter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Sylius\Component\Mailer\Renderer\RenderedEmail; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Sylius\Component\Mailer\SyliusMailerEvents; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | final class EmailTwigAdapterSpec extends ObjectBehavior | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     function let(\Twig_Environment $twig): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->beConstructedWith($twig); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     function it_is_an_adapter(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->shouldHaveType(AbstractAdapter::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     function it_renders_an_email( | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         \Twig_Environment $twig, | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |         \Twig_Template $template, | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |         EmailInterface $email, | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         EmailRenderEvent $event, | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         EventDispatcherInterface $dispatcher, | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         RenderedEmail $renderedEmail | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     ): void { | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |         $this->setEventDispatcher($dispatcher); | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |         $twig->mergeGlobals([])->shouldBeCalled()->willReturn([]); | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         $email->getTemplate()->shouldBeCalled()->willReturn('MyTemplate'); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         $twig->loadTemplate('MyTemplate')->shouldBeCalled()->willReturn($template); | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         $template->renderBlock('subject', [])->willReturn('template'); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         $template->renderBlock('body', [])->willReturn('body'); | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         $dispatcher->dispatch( | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             SyliusMailerEvents::EMAIL_PRE_RENDER, | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |             Argument::type(EmailRenderEvent::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         )->shouldBeCalled()->willReturn($event); | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         $event->getRenderedEmail()->shouldBeCalled()->willReturn($renderedEmail); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         $this->render($email, [])->shouldReturn($renderedEmail); | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     function it_creates_and_renders_an_email( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         EmailInterface $email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         EmailRenderEvent $event, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         EventDispatcherInterface $dispatcher, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         RenderedEmail $renderedEmail | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     ): void { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->setEventDispatcher($dispatcher); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $email->getTemplate()->shouldBeCalled()->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $email->getSubject()->shouldBeCalled()->willReturn('subject'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         $email->getContent()->shouldBeCalled()->willReturn('content'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $dispatcher->dispatch( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             SyliusMailerEvents::EMAIL_PRE_RENDER, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             Argument::type(EmailRenderEvent::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         )->shouldBeCalled()->willReturn($event); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $event->getRenderedEmail()->shouldBeCalled()->willReturn($renderedEmail); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->render($email, [])->shouldReturn($renderedEmail); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 87 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.