public function testGetTree()
 {
     $accountUserRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $accountUserManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $accountUserManager->expects($this->any())->method('getRepository')->with(self::ACCOUNT_USER_CLASS)->willReturn($accountUserRepository);
     $AccountRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $accountManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $accountManager->expects($this->any())->method('getRepository')->with(self::ACCOUNT_CLASS)->willReturn($AccountRepository);
     $this->ownershipMetadataProvider->expects($this->any())->method('getBasicLevelClass')->willReturn(self::ACCOUNT_USER_CLASS);
     $this->ownershipMetadataProvider->expects($this->any())->method('getLocalLevelClass')->willReturn(self::ACCOUNT_CLASS);
     $this->managerRegistry->expects($this->any())->method('getManagerForClass')->willReturnMap([[self::ACCOUNT_USER_CLASS, $accountUserManager], [self::ACCOUNT_CLASS, $accountManager]]);
     list($accountUsers, $accounts) = $this->getTestData();
     $accountUserRepository->expects($this->any())->method('findAll')->will($this->returnValue($accountUsers));
     $AccountRepository->expects($this->any())->method('findAll')->will($this->returnValue($accounts));
     $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $accountUserManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($metadata));
     $metadata->expects($this->any())->method('getTableName')->will($this->returnValue('test'));
     $connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $accountUserManager->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $connection->expects($this->any())->method('isConnected')->will($this->returnValue(true));
     $schemaManager = $this->getMockBuilder('Doctrine\\DBAL\\Schema\\MySqlSchemaManager')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('getSchemaManager')->will($this->returnValue($schemaManager));
     $schemaManager->expects($this->any())->method('listTableNames')->will($this->returnValue(['test']));
     $this->treeProvider->warmUpCache();
     /** @var OwnerTree $tree */
     $tree = $this->treeProvider->getTree();
     $this->assertTestData($tree);
 }
 public function testWarmUpCacheFilterConfigsByScope()
 {
     $config1 = new Config(new EntityConfigId('ownership', 'AcmeBundle\\Entity\\User'));
     $config2 = new Config(new EntityConfigId('ownership', 'AcmeBundle\\Entity\\Account'));
     $this->configProvider->expects($this->once())->method('getConfigs')->willReturn([$config1, $config2]);
     $this->securityConfigProvider->expects($this->atLeastOnce())->method('hasConfig')->willReturn(true);
     $securityConfig1 = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $securityConfig1->expects($this->once())->method('get')->with('group_name')->willReturn('');
     $securityConfig2 = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $securityConfig2->expects($this->once())->method('get')->with('group_name')->willReturn('commerce');
     $this->securityConfigProvider->expects($this->atLeastOnce())->method('getConfig')->will($this->onConsecutiveCalls($securityConfig1, $securityConfig2));
     $this->cache->expects($this->once())->method('fetch')->with($this->equalTo('AcmeBundle\\Entity\\Account'));
     $this->provider->warmUpCache();
 }