public function testUnValidBusinessUnit() { $this->businessUnit->setId(1); $this->businessUnit->setOwner($this->businessUnit); $this->context->expects($this->once())->method('addViolation'); $this->businessUnitOwnerValidator->validate($this->businessUnit, $this->constraint); }
/** * @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]]; }
public function testReverseTransform() { $testResult = new ArrayCollection(); $bu1 = new BusinessUnit(); $bu1->setId(1); $testResult->add($bu1); $bu2 = new BusinessUnit(); $bu1->setId(2); $testResult->add($bu2); $buRepo = $this->getMockBuilder('Oro\\Bundle\\OrganizationBundle\\Entity\\Repository\\BusinessUnitRepository')->disableOriginalConstructor()->getMock(); $this->buManager->expects($this->any())->method('getBusinessUnitRepo')->will($this->returnValue($buRepo)); $buRepo->expects($this->once())->method('findBy')->with(['id' => [1, 2]])->will($this->returnValue($testResult)); $this->assertSame($testResult, $this->transformer->reverseTransform([1, 2])); $bu = new BusinessUnit(); $bu->setId(1); $buRepo->expects($this->once())->method('find')->with(1)->will($this->returnValue($bu)); $this->assertSame($bu, $this->transformer->reverseTransform(1)); }