/**
  * {@inheritDoc}
  *
  * @return ObjectMultiCheckbox
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $entityManager = $container->get('Doctrine\\ORM\\EntityManager');
     $element = new ObjectMultiCheckbox();
     $element->getProxy()->setObjectManager($entityManager);
     return $element;
 }
 protected function prepareProxy()
 {
     $objectClass = 'DoctrineModuleTest\\Form\\Element\\TestAsset\\FormObject';
     $objectOne = new FormObject();
     $objectTwo = new FormObject();
     $objectOne->setId(1)->setUsername('object one username')->setPassword('object one password')->setEmail('object one email')->setFirstname('object one firstname')->setSurname('object one surname');
     $objectTwo->setId(2)->setUsername('object two username')->setPassword('object two password')->setEmail('object two email')->setFirstname('object two firstname')->setSurname('object two surname');
     $this->values = $result = new ArrayCollection(array($objectOne, $objectTwo));
     $metadata = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $metadata->expects($this->any())->method('getIdentifierValues')->will($this->returnCallback(function () use($objectOne, $objectTwo) {
         $input = func_get_args();
         $input = array_shift($input);
         if ($input == $objectOne) {
             return array('id' => 1);
         } elseif ($input == $objectTwo) {
             return array('id' => 2);
         }
         return array();
     }));
     $objectRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $objectRepository->expects($this->any())->method('findAll')->will($this->returnValue($result));
     $objectManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $objectManager->expects($this->any())->method('getClassMetadata')->with($this->equalTo($objectClass))->will($this->returnValue($metadata));
     $objectManager->expects($this->any())->method('getRepository')->with($this->equalTo($objectClass))->will($this->returnValue($objectRepository));
     $this->element->getProxy()->setOptions(array('object_manager' => $objectManager, 'target_class' => $objectClass));
     $this->metadata = $metadata;
 }
 public function testOptionsCanBeSetSingle()
 {
     $proxy = $this->getMock('DoctrineModule\\Form\\Element\\Proxy');
     $proxy->expects($this->once())->method('setOptions')->with(array('is_method' => true));
     $this->setProxyViaReflection($proxy);
     $this->element->setOption('is_method', true);
 }
 /**
  * {@inheritDoc}
  */
 public function createService(ServiceLocatorInterface $pluginManager)
 {
     $services = $pluginManager->getServiceLocator();
     $entityManager = $services->get('Doctrine\\ORM\\EntityManager');
     $element = new ObjectMultiCheckbox();
     $element->getProxy()->setObjectManager($entityManager);
     return $element;
 }
 public function testGetValueOptionsDoesntInvokeProxyIfOptionsNotEmpty()
 {
     $options = array('foo' => 'bar');
     $proxy = $this->getMock('DoctrineModule\\Form\\Element\\Proxy');
     $proxy->expects($this->once())->method('getValueOptions')->will($this->returnValue($options));
     $this->setProxyViaReflection($proxy);
     $this->assertEquals($options, $this->element->getValueOptions());
     $this->assertEquals($options, $this->element->getValueOptions());
 }