public function testApplyTemplatesConfiguration()
 {
     $container = $this->getContainer();
     $this->extension->load(array($this->getConfig()), $container);
     $compilerPass = new AddDependencyCallsCompilerPass();
     $compilerPass->process($container);
     $callsPostAdmin = $container->getDefinition('sonata_post_admin')->getMethodCalls();
     foreach ($callsPostAdmin as $call) {
         list($name, $parameters) = $call;
         switch ($name) {
             case 'setTemplates':
                 $this->assertSame('foobar.twig.html', $parameters[0]['user_block']);
                 $this->assertSame('SonataAdminBundle:Pager:results.html.twig', $parameters[0]['pager_results']);
                 break;
             case 'setLabel':
                 $this->assertSame('-', $parameters[0]);
                 break;
             case 'setPagerType':
                 $this->assertSame('default', $parameters[0]);
                 break;
         }
     }
     $callsNewsAdmin = $container->getDefinition('sonata_news_admin')->getMethodCalls();
     foreach ($callsNewsAdmin as $call) {
         list($name, $parameters) = $call;
         switch ($name) {
             case 'setTemplates':
                 $this->assertSame('foo.twig.html', $parameters[0]['user_block']);
                 $this->assertSame('SonataAdminBundle:Pager:simple_pager_results.html.twig', $parameters[0]['pager_results']);
                 break;
             case 'setLabel':
                 $this->assertSame('Foo', $parameters[0]);
                 break;
             case 'setPagerType':
                 $this->assertSame('simple', $parameters[0]);
                 break;
         }
     }
 }
 /**
  * @covers Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass::process
  */
 public function testProcessGroupNameAsParameter()
 {
     $config = array('dashboard' => array('groups' => array('%sonata.admin.parameter.groupname%' => array())));
     $container = $this->getContainer();
     $container->setParameter('sonata.admin.parameter.groupname', 'resolved_group_name');
     $this->extension->load(array($config), $container);
     $compilerPass = new AddDependencyCallsCompilerPass();
     $compilerPass->process($container);
     $container->compile();
     $adminGroups = $container->get('sonata.admin.pool')->getAdminGroups();
     $this->assertArrayHasKey('resolved_group_name', $adminGroups);
     $this->assertFalse(array_key_exists('%sonata.admin.parameter.groupname%', $adminGroups));
 }
 public function testProcessMultipleOnTopOptionsInServiceDefinition2()
 {
     $container = $this->getContainer();
     $config = $this->config;
     $config['dashboard']['groups'] = array();
     $this->extension->load(array($config), $container);
     $compilerPass = new AddDependencyCallsCompilerPass();
     $container->register('sonata_document_one_admin')->setClass('Sonata\\AdminBundle\\Tests\\DependencyInjection\\MockAdmin')->setArguments(array('', 'Sonata\\AdminBundle\\Tests\\DependencyInjection\\ReportOne', 'SonataAdminBundle:CRUD'))->addTag('sonata.admin', array('group' => 'sonata_document_group', 'manager_type' => 'orm', 'on_top' => false));
     $container->register('sonata_document_two_admin')->setClass('Sonata\\AdminBundle\\Tests\\DependencyInjection\\MockAdmin')->setArguments(array('', 'Sonata\\AdminBundle\\Tests\\DependencyInjection\\ReportOne', 'SonataAdminBundle:CRUD'))->addTag('sonata.admin', array('group' => 'sonata_document_group', 'manager_type' => 'orm', 'on_top' => false));
     try {
         $compilerPass->process($container);
     } catch (\RuntimeException $e) {
         $this->fail('An expected exception has been raised.');
     }
 }