| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the Sonata Project package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Thomas Rabaix <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  | namespace Sonata\AdminBundle\Tests\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Prophecy\Argument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Sonata\AdminBundle\Admin\AbstractAdmin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sonata\AdminBundle\Admin\AdminHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sonata\AdminBundle\Admin\FieldDescriptionInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sonata\AdminBundle\Admin\Pool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Sonata\AdminBundle\Controller\HelperController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Sonata\AdminBundle\Datagrid\DatagridInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Sonata\AdminBundle\Datagrid\Pager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Sonata\AdminBundle\Model\ModelManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Sonata\AdminBundle\Templating\TemplateRegistryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Sonata\AdminBundle\Tests\Fixtures\Bundle\Entity\Foo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Sonata\AdminBundle\Tests\Fixtures\Filter\FooFilter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Sonata\AdminBundle\Twig\Extension\SonataAdminExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Sonata\CoreBundle\Model\Metadata; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Symfony\Bridge\Twig\AppVariable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use Symfony\Bridge\Twig\Command\DebugCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use Symfony\Bridge\Twig\Extension\FormExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use Symfony\Bridge\Twig\Form\TwigRenderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use Symfony\Component\DependencyInjection\ContainerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use Symfony\Component\Form\Form; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use Symfony\Component\Form\FormBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use Symfony\Component\Form\FormConfigInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use Symfony\Component\Form\FormRenderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use Symfony\Component\Form\FormView; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | use Symfony\Component\HttpFoundation\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | use Symfony\Component\HttpFoundation\Response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | use Symfony\Component\PropertyAccess\PropertyAccessor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | use Symfony\Component\Security\Core\Exception\AccessDeniedException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | use Symfony\Component\Translation\TranslatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | use Symfony\Component\Validator\ConstraintViolation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | use Symfony\Component\Validator\ConstraintViolationList; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | use Symfony\Component\Validator\Validator\ValidatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | use Twig\Environment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | use Twig\Template; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | use Twig\TemplateWrapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | class AdminControllerHelper_Foo | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     private $bar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function getAdminTitle() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         return 'foo'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     public function setEnabled($value) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     public function setBar(AdminControllerHelper_Bar $bar) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->bar = $bar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function getBar() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         return $this->bar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | class AdminControllerHelper_Bar | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function getAdminTitle() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         return 'bar'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     public function setEnabled($value) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     public function getEnabled() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | class HelperControllerTest extends TestCase | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @var Pool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     private $pool; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @var Environment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     private $twig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @var AdminHelper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     private $helper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @var ValidatorInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     private $validator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @var AbstractAdmin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     private $admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * @var HelperController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     private $controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $this->pool = $this->prophesize(Pool::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $this->twig = $this->prophesize(Environment::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $this->helper = $this->prophesize(AdminHelper::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $this->validator = $this->prophesize(ValidatorInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $this->admin = $this->prophesize(AbstractAdmin::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         $this->pool->getInstance(Argument::any())->willReturn($this->admin->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         $this->admin->setRequest(Argument::type(Request::class))->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $this->controller = new HelperController( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             $this->twig->reveal(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $this->pool->reveal(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             $this->helper->reveal(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             $this->validator->reveal() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     public function testGetShortObjectDescriptionActionInvalidAdmin() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $this->expectException(NotFoundHttpException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             'uniqid' => 'asdasd123', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         $this->pool->getInstance('sonata.post.admin')->willReturn(null); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         $this->admin->setRequest(Argument::type(Request::class))->shouldNotBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         $this->controller->getShortObjectDescriptionAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     public function testGetShortObjectDescriptionActionObjectDoesNotExist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $this->expectException(\RuntimeException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $this->expectExceptionMessage('Invalid format'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             'uniqid' => 'asdasd123', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         $this->admin->setUniqid('asdasd123')->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $this->admin->getObject(42)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         $this->controller->getShortObjectDescriptionAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     public function testGetShortObjectDescriptionActionEmptyObjectId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             'objectId' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             'uniqid' => 'asdasd123', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             '_format' => 'html', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         $this->admin->setUniqid('asdasd123')->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $this->admin->getObject(null)->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $response = $this->controller->getShortObjectDescriptionAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         $this->assertInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     public function testGetShortObjectDescriptionActionObject() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             'uniqid' => 'asdasd123', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |             '_format' => 'html', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $this->admin->setUniqid('asdasd123')->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         $this->admin->getObject(42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $this->admin->getTemplate('short_object_description')->willReturn('template'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         $this->admin->toString($object)->willReturn('bar'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         $this->twig->render('template', [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             'admin' => $this->admin->reveal(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             'description' => 'bar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |             'object' => $object, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             'link_parameters' => [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         ])->willReturn('renderedTemplate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $response = $this->controller->getShortObjectDescriptionAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $this->assertSame('renderedTemplate', $response->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     public function testSetObjectFieldValueAction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             'field' => 'enabled', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             'context' => 'list', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'POST', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         $fieldDescription = $this->prophesize(FieldDescriptionInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $pool = $this->prophesize(Pool::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $template = $this->prophesize(Template::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $translator = $this->prophesize(TranslatorInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         $propertyAccessor = new PropertyAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $templateRegistry = $this->prophesize(TemplateRegistryInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         $container = $this->prophesize(ContainerInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         $this->admin->getObject(42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         $this->admin->getCode()->willReturn('sonata.post.admin'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         $this->admin->hasAccess('edit', $object)->willReturn(true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $this->admin->getListFieldDescription('enabled')->willReturn($fieldDescription->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         $this->admin->update($object)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         // NEXT_MAJOR: Remove this line | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         $this->admin->getTemplate('base_list_field')->willReturn('admin_template'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         $templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         $container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         $this->pool->getPropertyAccessor()->willReturn($propertyAccessor); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         $this->twig->getExtension(SonataAdminExtension::class)->willReturn( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             new SonataAdminExtension($pool->reveal(), null, $translator->reveal(), $container->reveal()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         $this->twig->load('admin_template')->willReturn(new TemplateWrapper($this->twig->reveal(), $template->reveal())); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         $this->twig->isDebug()->willReturn(false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $fieldDescription->getOption('editable')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $fieldDescription->getAdmin()->willReturn($this->admin->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |         $fieldDescription->getType()->willReturn('boolean'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         $fieldDescription->getTemplate()->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |         $fieldDescription->getValue(Argument::cetera())->willReturn('some value'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         $this->validator->validate($object)->willReturn(new ConstraintViolationList([])); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         $response = $this->controller->setObjectFieldValueAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         $this->assertEquals(200, $response->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     public function testSetObjectFieldValueActionOnARelationField() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         $associationObject = new AdminControllerHelper_Bar(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             'field' => 'bar', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             'context' => 'list', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'POST', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         $fieldDescription = $this->prophesize(FieldDescriptionInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $modelManager = $this->prophesize(ModelManagerInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         $template = $this->prophesize(Template::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |         $translator = $this->prophesize(TranslatorInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         $propertyAccessor = new PropertyAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         $templateRegistry = $this->prophesize(TemplateRegistryInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         $container = $this->prophesize(ContainerInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $this->admin->getObject(42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         $this->admin->getCode()->willReturn('sonata.post.admin'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         $this->admin->hasAccess('edit', $object)->willReturn(true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $this->admin->getListFieldDescription('bar')->willReturn($fieldDescription->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         $this->admin->getClass()->willReturn(get_class($object)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         $this->admin->update($object)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         // NEXT_MAJOR: Remove this line | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         $this->admin->getTemplate('base_list_field')->willReturn('admin_template'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         $templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         $this->admin->getModelManager()->willReturn($modelManager->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         $this->validator->validate($object)->willReturn(new ConstraintViolationList([])); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         $this->twig->getExtension(SonataAdminExtension::class)->willReturn( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             new SonataAdminExtension($this->pool->reveal(), null, $translator->reveal(), $container->reveal()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |         $this->twig->load('field_template')->willReturn(new TemplateWrapper($this->twig->reveal(), $template->reveal())); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |         $this->twig->isDebug()->willReturn(false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |         $this->pool->getPropertyAccessor()->willReturn($propertyAccessor); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |         $fieldDescription->getType()->willReturn('choice'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         $fieldDescription->getOption('editable')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         $fieldDescription->getOption('class')->willReturn(AdminControllerHelper_Bar::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         $fieldDescription->getTargetEntity()->willReturn(AdminControllerHelper_Bar::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         $fieldDescription->getAdmin()->willReturn($this->admin->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |         $fieldDescription->getTemplate()->willReturn('field_template'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         $fieldDescription->getValue(Argument::cetera())->willReturn('some value'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |         $modelManager->find(get_class($associationObject), 1)->willReturn($associationObject); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         $response = $this->controller->setObjectFieldValueAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         $this->assertEquals(200, $response->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     public function testAppendFormFieldElementAction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             'field' => 'enabled', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |             'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |             'context' => 'list', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'POST']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |         $modelManager = $this->prophesize(ModelManagerInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         $formView = new FormView(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |         $form = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |         $renderer = $this->configureFormRenderer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |         $this->admin->getObject(42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |         $this->admin->getClass()->willReturn(get_class($object)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         $this->admin->setSubject($object)->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         $this->admin->getFormTheme()->willReturn($formView); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         $this->helper->appendFormFieldElement($this->admin->reveal(), $object, null)->willReturn([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |             $this->prophesize(FieldDescriptionInterface::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |             $form->reveal(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         $this->helper->getChildFormView($formView, null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |             ->willReturn($formView); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         $modelManager->find(get_class($object), 42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         $form->createView()->willReturn($formView); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         $renderer->setTheme($formView, $formView)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         $renderer->searchAndRenderBlock($formView, 'widget')->willReturn('block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |         $response = $this->controller->appendFormFieldElementAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $this->isInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $this->assertSame($response->getContent(), 'block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     public function testRetrieveFormFieldElementAction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |             'field' => 'enabled', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |             'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |             'context' => 'list', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'POST']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $modelManager = $this->prophesize(ModelManagerInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         $formView = new FormView(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         $form = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |         $formBuilder = $this->prophesize(FormBuilder::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         $renderer = $this->configureFormRenderer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         $this->admin->getObject(42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         $this->admin->getClass()->willReturn(get_class($object)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         $this->admin->setSubject($object)->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         $this->admin->getFormTheme()->willReturn($formView); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         $this->admin->getFormBuilder()->willReturn($formBuilder->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         $this->helper->getChildFormView($formView, null) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |             ->willReturn($formView); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |         $modelManager->find(get_class($object), 42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         $form->setData($object)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         $form->handleRequest($request)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         $form->createView()->willReturn($formView); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |         $formBuilder->getForm()->willReturn($form->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |         $renderer->setTheme($formView, $formView)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |         $renderer->searchAndRenderBlock($formView, 'widget')->willReturn('block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |         $response = $this->controller->retrieveFormFieldElementAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         $this->isInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         $this->assertSame($response->getContent(), 'block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |     public function testSetObjectFieldValueActionWithViolations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         $bar = new AdminControllerHelper_Bar(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |         $object->setBar($bar); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |             'code' => 'sonata.post.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |             'objectId' => 42, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |             'field' => 'bar.enabled', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |             'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |             'context' => 'list', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'POST', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |         $fieldDescription = $this->prophesize(FieldDescriptionInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |         $propertyAccessor = new PropertyAccessor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         $this->pool->getPropertyAccessor()->willReturn($propertyAccessor); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         $this->admin->getObject(42)->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |         $this->admin->hasAccess('edit', $object)->willReturn(true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         $this->admin->getListFieldDescription('bar.enabled')->willReturn($fieldDescription->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         $this->validator->validate($bar)->willReturn(new ConstraintViolationList([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |             new ConstraintViolation('error1', null, [], null, 'enabled', null), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |             new ConstraintViolation('error2', null, [], null, 'enabled', null), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         $fieldDescription->getOption('editable')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |         $fieldDescription->getType()->willReturn('boolean'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         $response = $this->controller->setObjectFieldValueAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $this->assertEquals(400, $response->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |         $this->assertSame(json_encode("error1\nerror2"), $response->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 429 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 430 |  |  |     public function testRetrieveAutocompleteItemsActionNotGranted() | 
            
                                                                        
                            
            
                                    
            
            
                | 431 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 432 |  |  |         $this->expectException(AccessDeniedException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 434 |  |  |         $request = new Request([ | 
            
                                                                        
                            
            
                                    
            
            
                | 435 |  |  |             'admin_code' => 'foo.admin', | 
            
                                                                        
                            
            
                                    
            
            
                | 436 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'GET', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                        
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 438 |  |  |         $this->admin->hasAccess('create')->willReturn(false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 439 |  |  |         $this->admin->hasAccess('edit')->willReturn(false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 440 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 441 |  |  |         $this->controller->retrieveAutocompleteItemsAction($request); | 
            
                                                                        
                            
            
                                    
            
            
                | 442 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |     public function testRetrieveAutocompleteItemsActionDisabledFormelememt() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |         $this->expectException(AccessDeniedException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |         $this->expectExceptionMessage('Autocomplete list can`t be retrieved because the form element is disabled or read_only.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |             'admin_code' => 'foo.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |             'field' => 'barField', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'GET', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         $fieldDescription = $this->prophesize(FieldDescriptionInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         $this->configureFormConfig('barField', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |         $this->admin->getNewInstance()->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |         $this->admin->setSubject($object)->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |         $this->admin->hasAccess('create')->willReturn(true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |         $this->admin->getFormFieldDescriptions()->willReturn(null); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |         $this->admin->getFormFieldDescription('barField')->willReturn($fieldDescription->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |         $fieldDescription->getTargetEntity()->willReturn(Foo::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |         $fieldDescription->getName()->willReturn('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |         $this->controller->retrieveAutocompleteItemsAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |     public function testRetrieveAutocompleteItemsTooShortSearchString() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |         $object = new AdminControllerHelper_Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |             'admin_code' => 'foo.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |             'field' => 'barField', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |             'q' => 'so', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'GET', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |         $targetAdmin = $this->prophesize(AbstractAdmin::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |         $fieldDescription = $this->prophesize(FieldDescriptionInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |         $this->configureFormConfig('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |         $this->admin->getNewInstance()->willReturn($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |         $this->admin->setSubject($object)->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |         $this->admin->hasAccess('create')->willReturn(true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         $this->admin->getFormFieldDescription('barField')->willReturn($fieldDescription->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |         $this->admin->getFormFieldDescriptions()->willReturn(null); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         $targetAdmin->checkAccess('list')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $fieldDescription->getTargetEntity()->willReturn(Foo::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |         $fieldDescription->getName()->willReturn('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         $fieldDescription->getAssociationAdmin()->willReturn($targetAdmin->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |         $response = $this->controller->retrieveAutocompleteItemsAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |         $this->isInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |         $this->assertSame('application/json', $response->headers->get('Content-Type')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |         $this->assertSame('{"status":"KO","message":"Too short search string."}', $response->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |     public function testRetrieveAutocompleteItems() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |             'admin_code' => 'foo.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |             'field' => 'barField', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |             'q' => 'sonata', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'GET', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $this->configureFormConfig('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         $datagrid = $this->configureAutocompleteItemsDatagrid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         $filter = new FooFilter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         $filter->initialize('foo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         $datagrid->hasFilter('foo')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |         $datagrid->getFilter('foo')->willReturn($filter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |         $datagrid->setValue('foo', null, 'sonata')->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |         $response = $this->controller->retrieveAutocompleteItemsAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |         $this->isInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |         $this->assertSame('application/json', $response->headers->get('Content-Type')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         $this->assertSame('{"status":"OK","more":false,"items":[{"id":123,"label":"FOO"}]}', $response->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |     public function testRetrieveAutocompleteItemsComplexPropertyArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             'admin_code' => 'foo.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |             'field' => 'barField', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |             'q' => 'sonata', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'GET', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |         $this->configureFormConfigComplexPropertyArray('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |         $datagrid = $this->configureAutocompleteItemsDatagrid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |         $filter = new FooFilter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         $filter->initialize('entity.property'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |         $datagrid->hasFilter('entity.property')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |         $datagrid->getFilter('entity.property')->willReturn($filter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |         $filter2 = new FooFilter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         $filter2->initialize('entity2.property2'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         $datagrid->hasFilter('entity2.property2')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |         $datagrid->getFilter('entity2.property2')->willReturn($filter2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         $datagrid->setValue('entity__property', null, 'sonata')->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |         $datagrid->setValue('entity2__property2', null, 'sonata')->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |         $response = $this->controller->retrieveAutocompleteItemsAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |         $this->isInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |         $this->assertSame('application/json', $response->headers->get('Content-Type')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |         $this->assertSame('{"status":"OK","more":false,"items":[{"id":123,"label":"FOO"}]}', $response->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |     public function testRetrieveAutocompleteItemsComplexProperty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |         $request = new Request([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |             'admin_code' => 'foo.admin', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |             'field' => 'barField', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |             'q' => 'sonata', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |         ], [], [], [], [], ['REQUEST_METHOD' => 'GET', 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |         $this->configureFormConfigComplexProperty('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |         $datagrid = $this->configureAutocompleteItemsDatagrid(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |         $filter = new FooFilter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |         $filter->initialize('entity.property'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |         $datagrid->hasFilter('entity.property')->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |         $datagrid->getFilter('entity.property')->willReturn($filter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         $datagrid->setValue('entity__property', null, 'sonata')->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |         $response = $this->controller->retrieveAutocompleteItemsAction($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |         $this->isInstanceOf(Response::class, $response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |         $this->assertSame('application/json', $response->headers->get('Content-Type')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |         $this->assertSame('{"status":"OK","more":false,"items":[{"id":123,"label":"FOO"}]}', $response->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |     private function configureAutocompleteItemsDatagrid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |         $entity = new Foo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |         $targetAdmin = $this->prophesize(AbstractAdmin::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |         $datagrid = $this->prophesize(DatagridInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |         $metadata = $this->prophesize(Metadata::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |         $pager = $this->prophesize(Pager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |         $fieldDescription = $this->prophesize(FieldDescriptionInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |         $this->admin->getNewInstance()->willReturn($entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |         $this->admin->setSubject($entity)->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |         $this->admin->hasAccess('create')->willReturn(true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |         $this->admin->getFormFieldDescription('barField')->willReturn($fieldDescription->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |         $this->admin->getFormFieldDescriptions()->willReturn(null); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |         $this->admin->id($entity)->willReturn(123); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |         $targetAdmin->checkAccess('list')->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |         $targetAdmin->setFilterPersister(null)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |         $targetAdmin->getDatagrid()->willReturn($datagrid->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |         $targetAdmin->getObjectMetadata($entity)->willReturn($metadata->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |         $metadata->getTitle()->willReturn('FOO'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |         $datagrid->setValue('_per_page', null, 10)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |         $datagrid->setValue('_page', null, 1)->shouldBeCalled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |         $datagrid->buildPager()->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |         $datagrid->getPager()->willReturn($pager->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |         $pager->getResults()->willReturn([$entity]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |         $pager->isLastPage()->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |         $fieldDescription->getTargetEntity()->willReturn(Foo::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |         $fieldDescription->getName()->willReturn('barField'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |         $fieldDescription->getAssociationAdmin()->willReturn($targetAdmin->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |         return $datagrid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |     private function configureFormConfig($field, $disabled = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |         $form = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |         $formType = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |         $formConfig = $this->prophesize(FormConfigInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |         $this->admin->getForm()->willReturn($form->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |         $form->get($field)->willReturn($formType->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |         $formType->getConfig()->willReturn($formConfig->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |         $formConfig->getAttribute('disabled')->willReturn($disabled); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |         $formConfig->getAttribute('property')->willReturn('foo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |         $formConfig->getAttribute('callback')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |         $formConfig->getAttribute('minimum_input_length')->willReturn(3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |         $formConfig->getAttribute('items_per_page')->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |         $formConfig->getAttribute('req_param_name_page_number')->willReturn('_page'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |         $formConfig->getAttribute('to_string_callback')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |         $formConfig->getAttribute('target_admin_access_action')->willReturn('list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |     private function configureFormConfigComplexProperty($field) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         $form = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |         $formType = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |         $formConfig = $this->prophesize(FormConfigInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |         $this->admin->getForm()->willReturn($form->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |         $form->get($field)->willReturn($formType->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |         $formType->getConfig()->willReturn($formConfig->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |         $formConfig->getAttribute('disabled')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |         $formConfig->getAttribute('property')->willReturn('entity.property'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |         $formConfig->getAttribute('callback')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |         $formConfig->getAttribute('minimum_input_length')->willReturn(3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |         $formConfig->getAttribute('items_per_page')->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |         $formConfig->getAttribute('req_param_name_page_number')->willReturn('_page'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |         $formConfig->getAttribute('to_string_callback')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |         $formConfig->getAttribute('target_admin_access_action')->willReturn('list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     private function configureFormConfigComplexPropertyArray($field) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |         $form = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |         $formType = $this->prophesize(Form::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |         $formConfig = $this->prophesize(FormConfigInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |         $this->admin->getForm()->willReturn($form->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |         $form->get($field)->willReturn($formType->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |         $formType->getConfig()->willReturn($formConfig->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |         $formConfig->getAttribute('disabled')->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |         $formConfig->getAttribute('property')->willReturn(['entity.property', 'entity2.property2']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |         $formConfig->getAttribute('callback')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         $formConfig->getAttribute('minimum_input_length')->willReturn(3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |         $formConfig->getAttribute('items_per_page')->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |         $formConfig->getAttribute('req_param_name_page_number')->willReturn('_page'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |         $formConfig->getAttribute('to_string_callback')->willReturn(null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |         $formConfig->getAttribute('target_admin_access_action')->willReturn('list'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |     private function configureFormRenderer() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         $runtime = $this->prophesize(FormRenderer::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |         // Remove the condition when dropping sf < 3.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |         if (!method_exists(AppVariable::class, 'getToken')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |             $extension = $this->prophesize(FormExtension::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |             $this->twig->getExtension(FormExtension::class)->willReturn($extension->reveal()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |             $extension->initRuntime($this->twig->reveal())->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |             $extension->renderer = $runtime->reveal(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |             return $runtime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |         // Remove the condition when dropping sf < 3.4 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |         if (!method_exists(DebugCommand::class, 'getLoaderPaths')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |             $twigRuntime = $this->prophesize(TwigRenderer::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |             $this->twig->getRuntime(TwigRenderer::class)->willReturn($twigRuntime->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |             $twigRuntime->setEnvironment($this->twig->reveal())->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |             return $twigRuntime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |         $this->twig->getRuntime(FormRenderer::class)->willReturn($runtime->reveal()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |         return $runtime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 705 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 706 |  |  |  | 
            
                        
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider.