protected function setUp() { $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry'); $managerRegistry->expects($this->any())->method('getManagerForClass')->willReturn($this->em); $this->cache = $this->getMockForAbstractClass('Doctrine\\Common\\Cache\\CacheProvider'); $this->cache->expects($this->any())->method('fetch')->will($this->returnValue(false)); $this->cache->expects($this->any())->method('save'); $this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock(); $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->container->expects($this->any())->method('get')->will($this->returnValueMap([['oro_security.ownership_tree_provider.cache', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->cache], ['oro_security.owner.ownership_metadata_provider', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, new OwnershipMetadataProviderStub($this, ['user' => 'Oro\\Bundle\\UserBundle\\Entity\\User', 'business_unit' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\BusinessUnit'])], ['doctrine', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $managerRegistry], ['oro_security.security_facade', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->securityFacade]])); $this->treeProvider = new OwnerTreeProvider($this->em, $this->cache); $this->treeProvider->setContainer($this->container); }