public function preSetData()
 {
     $entityConfigId = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\Id\\EntityConfigId')->disableOriginalConstructor()->getMock();
     $user = new User();
     $user->setId(1);
     $organization = new Organization();
     $organization->setId(3);
     $userConfig = new Config($entityConfigId);
     $userConfig->setValues(["owner_type" => "USER", "owner_field_name" => "owner", "owner_column_name" => "owner_id", "organization_field_name" => "organization", "organization_column_name" => "organization_id"]);
     $buConfig = new Config($entityConfigId);
     $buConfig->setValues(["owner_type" => "BUSINESS_UNIT", "owner_field_name" => "owner", "owner_column_name" => "owner_id", "organization_field_name" => "organization", "organization_column_name" => "organization_id"]);
     $organizationConfig = new Config($entityConfigId);
     $organizationConfig->setValues(["owner_type" => "ORGANIZATION", "owner_field_name" => "owner", "owner_column_name" => "owner_id"]);
     return ['OwnershipType User with UsernamePasswordOrganizationToken' => [new UsernamePasswordOrganizationToken($user, 'admin', 'key', $organization), $userConfig, ['owner' => $user, 'organization' => $organization]], 'OwnershipType BusinessUnit with UsernamePasswordOrganizationToken' => [new UsernamePasswordOrganizationToken($user, 'admin', 'key', $organization), $buConfig, ['organization' => $organization]], 'OwnershipType Organization with UsernamePasswordOrganizationToken' => [new UsernamePasswordOrganizationToken($user, 'admin', 'key', $organization), $organizationConfig, ['owner' => $organization]], 'OwnershipType User with UsernamePasswordToken' => [new UsernamePasswordToken($user, 'admin', 'key'), $userConfig, ['owner' => $user]], 'OwnershipType BusinessUnit with UsernamePasswordToken' => [new UsernamePasswordToken($user, 'admin', 'key'), $buConfig, []], 'OwnershipType Organization with UsernamePasswordToken' => [new UsernamePasswordToken($user, 'admin', 'key'), $organizationConfig, []]];
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @return array
  */
 public function dataProvider()
 {
     $organization1 = new Organization();
     $organization1->setId(1);
     $organization2 = new Organization();
     $organization2->setId(2);
     $bu11 = new BusinessUnit();
     $bu11->setId(1);
     $bu11->setOrganization($organization1);
     $bu22 = new BusinessUnit();
     $bu22->setId(2);
     $bu22->setOrganization($organization2);
     $newUser = new User();
     $newUser->setId(2);
     $newUser->setOrganizations(new ArrayCollection([$organization1]));
     $newUser->setBusinessUnits(new ArrayCollection([$bu11]));
     return ['BASIC_LEVEL access level, current user' => [$this->getCurrentUser(2, [$organization1], [$bu11]), $newUser, AccessLevel::BASIC_LEVEL, $organization1, true], 'BASIC_LEVEL access level, another user' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::BASIC_LEVEL, $organization1, false], 'SYSTEM_LEVEL access level, current user' => [$this->getCurrentUser(2, [$organization1], [$bu11]), $newUser, AccessLevel::SYSTEM_LEVEL, $organization1, true], 'SYSTEM_LEVEL access level, another user' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::SYSTEM_LEVEL, $organization1, true], 'GLOBAL_LEVEL access level, current user' => [$this->getCurrentUser(2, [$organization1], [$bu11]), $newUser, AccessLevel::GLOBAL_LEVEL, $organization1, true], 'GLOBAL_LEVEL access level, another user, same org' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::GLOBAL_LEVEL, $organization1, true], 'GLOBAL_LEVEL access level, another user, different org' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::GLOBAL_LEVEL, $organization2, false], 'LOCAL_LEVEL access level, current user' => [$this->getCurrentUser(2, [$organization1], [$bu11]), $newUser, AccessLevel::LOCAL_LEVEL, $organization1, true], 'LOCAL_LEVEL access level, another user, same org' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::LOCAL_LEVEL, $organization1, true], 'LOCAL_LEVEL access level, another user, different org' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::LOCAL_LEVEL, $organization2, false], 'DEEP_LEVEL access level, current user' => [$this->getCurrentUser(2, [$organization1], [$bu11]), $newUser, AccessLevel::DEEP_LEVEL, $organization1, true], 'DEEP_LEVEL access level, another user, same org' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::DEEP_LEVEL, $organization1, true], 'DEEP_LEVEL access level, another user, different org' => [$this->getCurrentUser(1, [$organization1], [$bu11]), $newUser, AccessLevel::DEEP_LEVEL, $organization2, false]];
 }
 protected function mockConfigs(array $values)
 {
     $this->securityFacade->expects($this->any())->method('getOrganization')->will($this->returnValue($this->organization));
     $this->securityFacade->expects($this->any())->method('getOrganizationId')->will($this->returnValue($this->organization->getId()));
     $this->securityFacade->expects($this->any())->method('getLoggedUser')->will($this->returnValue($this->user));
     $this->securityFacade->expects($this->any())->method('isGranted')->will($this->returnValue($values['is_granted']));
     $metadata = OwnershipType::OWNER_TYPE_NONE === $values['owner_type'] ? new OwnershipMetadata($values['owner_type']) : new OwnershipMetadata($values['owner_type'], 'owner', 'owner_id');
     $this->ownershipMetadataProvider->expects($this->any())->method('getMetadata')->with($this->entityClassName)->will($this->returnValue($metadata));
     $aclVoter = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Acl\\Voter\\AclVoter')->disableOriginalConstructor()->getMock();
     $treeProvider = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Owner\\OwnerTreeProvider')->disableOriginalConstructor()->getMock();
     $this->extension = new OwnerFormExtension($this->doctrineHelper, $this->ownershipMetadataProvider, $this->businessUnitManager, $this->securityFacade, $aclVoter, $treeProvider, $this->entityOwnerAccessor);
 }