/**
  * Sets up the fixture.
  *
  * @covers Kunstmaan\PagePartBundle\EventListener\CloneListener::__construct
  */
 protected function setUp()
 {
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->repo = $this->getMockBuilder(PagePartRefRepository::class)->disableOriginalConstructor()->getMock();
     $this->em->expects($this->any())->method('getRepository')->with($this->equalTo('KunstmaanPagePartBundle:PagePartRef'))->will($this->returnValue($this->repo));
     $this->configurator = new PagePartAdminConfigurator();
     $this->configurator->setContext('main');
     $this->reader = $this->getMock(PagePartConfigurationReaderInterface::class);
     $this->reader->expects($this->any())->method('getPagePartAdminConfigurators')->will($this->returnValue([$this->configurator]));
     $this->reader->expects($this->any())->method('getPagePartContexts')->will($this->returnValue([$this->configurator->getContext()]));
     $this->templateService = $this->getMockBuilder(PageTemplateConfigurationService::class)->disableOriginalConstructor()->getMock();
     $this->object = new CloneListener($this->em, $this->reader, $this->templateService);
 }
 /**
  * @param PagePartInterface $pagepart
  *
  * @return string
  */
 public function getType(PagePartInterface $pagepart)
 {
     $possiblePagePartTypes = $this->configurator->getPossiblePagePartTypes();
     foreach ($possiblePagePartTypes as &$pageparttype) {
         if ($pageparttype['class'] == ClassLookup::getClass($pagepart)) {
             return $pageparttype['name'];
         }
     }
     return "no name";
 }