public function testWithInvalidSettings()
 {
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $logger->expects($this->exactly(1))->method('error');
     $service = $this->getMock('Sonata\\BlockBundle\\Block\\AbstractBlockService');
     $service->expects($this->exactly(2))->method('setDefaultSettings');
     $blockLoader = $this->getMock('Sonata\\BlockBundle\\Block\\BlockLoaderInterface');
     $serviceManager = $this->getMock('Sonata\\BlockBundle\\Block\\BlockServiceManagerInterface');
     $serviceManager->expects($this->exactly(2))->method('get')->will($this->returnValue($service));
     $block = $this->getMock('Sonata\\BlockBundle\\Model\\BlockInterface');
     $block->expects($this->once())->method('getSettings')->will($this->returnValue(array('template' => array())));
     $manager = new BlockContextManager($blockLoader, $serviceManager, array(), $logger);
     $blockContext = $manager->get($block);
     $this->assertInstanceOf('Sonata\\BlockBundle\\Block\\BlockContextInterface', $blockContext);
 }
 /**
  * @param OptionsResolverInterface $optionsResolver
  * @param BlockInterface           $block
  */
 protected function setDefaultSettings(OptionsResolverInterface $optionsResolver, BlockInterface $block)
 {
     parent::setDefaultSettings($optionsResolver, $block);
     $optionsResolver->setDefaults(array('manager' => false, 'page_id' => false));
     $optionsResolver->addAllowedTypes(array('manager' => array('string', 'bool'), 'page_id' => array('int', 'string', 'bool')));
     $optionsResolver->setRequired(array('manager', 'page_id'));
 }
 /**
  * {@inheritdoc}
  */
 protected function configureSettings(OptionsResolver $optionsResolver, BlockInterface $block)
 {
     parent::configureSettings($optionsResolver, $block);
     $optionsResolver->setDefaults(array('manager' => false, 'page_id' => false));
     // TODO: Remove it when bumping requirements to SF 2.6+
     if (method_exists($optionsResolver, 'setDefined')) {
         $optionsResolver->addAllowedTypes('manager', array('string', 'bool'))->addAllowedTypes('page_id', array('int', 'string', 'bool'));
     } else {
         $optionsResolver->addAllowedTypes(array('manager' => array('string', 'bool'), 'page_id' => array('int', 'string', 'bool')));
     }
     $optionsResolver->setRequired(array('manager', 'page_id'));
 }