public function testSetName() { // new entity $department = new Department(); // Use the setName method $department->setName("NTNUx2"); // Assert the result $this->assertEquals("NTNUx2", $department->getName()); }
public function testSetDepartment() { // new entity $semester = new Semester(); // Dummy entity $department = new Department(); $department->setName("NTNU"); // Use the setDepartment method $semester->setDepartment($department); // Assert the result $this->assertEquals($department, $semester->getDepartment()); }
public function testSetDepartment() { // new entity $team = new Team(); // dummy entity $department = new Department(); $department->setName("NTNU"); // Use the setDepartment method $team->setDepartment($department); // Assert the result $this->assertEquals($department, $team->getDepartment()); }
public function testSetDepartment() { // new entity $fos = new FieldOfStudy(); // A new test department entity $department = new Department(); $department->setName("NTNU"); // Use the setDepartment method $fos->setDepartment($department); // Assert the result $this->assertEquals($department, $fos->getDepartment()); }
/** * @Route("/admin/department/new", name="department-add") * @param Request $request * @return string|\Symfony\Component\HttpFoundation\Response * @Method("POST") */ public function departmentAddNewAction(Request $request) { //create new department $department = new Department(); $department->setName($request->request->get('department_name')); $this->get('department_manager')->save($department); foreach ($request->get('users') as $userId) { $user = $this->get('user_repository')->findByPk($userId); $department->addEmployee($user); } $doctrine = $this->container->get('doctrine'); $em = $doctrine->getManager(); $em->flush(); return $this->redirectToRoute('department-main'); }
public function load(ObjectManager $manager) { $department1 = new Department(); $department1->setName('Norges teknisk-naturvitenskapelige universitet'); $department1->setShortName('NTNU'); $department1->setEmail('*****@*****.**'); $department1->addSchool($this->getReference('school-1')); $department1->addSchool($this->getReference('school-2')); $department1->addSchool($this->getReference('school-3')); $department1->setAddress('Høgskoleringen 5 7491 Trondheim'); $manager->persist($department1); $department2 = new Department(); $department2->setName('Høgskolen i Sør-Trønderlag'); $department2->setShortName('HiST'); $department2->setEmail('*****@*****.**'); $department2->addSchool($this->getReference('school-2')); $department2->setAddress('*hist adresse*'); $manager->persist($department2); $department3 = new Department(); $department3->setName('Norges miljø- og biovitenskapelige universitet'); $department3->setShortName('NMBU'); $department3->setEmail('*****@*****.**'); $department3->addSchool($this->getReference('school-1')); $department3->setAddress('*NMBU adresse*'); $manager->persist($department3); $department4 = new Department(); $department4->setName('Universitetet i Oslo'); $department4->setShortName('UiO'); $department4->setEmail('*****@*****.**'); $department4->addSchool($this->getReference('school-2')); $department4->setAddress('*UiO adresse*'); $manager->persist($department4); $manager->flush(); $this->addReference('dep-1', $department1); $this->addReference('dep-2', $department2); $this->addReference('dep-3', $department3); $this->addReference('dep-4', $department4); }
public function testRemoveDepartment() { // new entity $school = new School(); $department1 = new Department(); $department1->setName("Department1"); $department2 = new Department(); $department2->setName("Department2"); $department3 = new Department(); $department3->setName("Department3"); // Use the addDepartment method $school->addDepartment($department1); $school->addDepartment($department2); $school->addDepartment($department3); // Remove $department1 $school->removeDepartment($department1); // Departments are stored in an array $departments = $school->getDepartments(); // Loop through the array foreach ($departments as $d) { // Assert the result $this->assertNotEquals($department1, $d); } }
/** * @Security("has_role('ROLE_SUPER_ADMIN')") * @Route("/users/newGroup/compete", name="newGroup") */ public function newDepartmentAction(Request $request) { $department = new Department(); $department->setName($request->get('_name')); $department->setCompany($this->getDoctrine()->getRepository('AppBundle:Company')->find($request->get('_company'))); $em = $this->getDoctrine()->getManager(); $em->persist($department); $em->flush(); return $this->redirectToRoute('adminPage'); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $stepDept = new Department(); $stepDept->setName('Home'); $stepDept->setOffice($this->getReference('stepOffice')); $manager->persist($stepDept); $oneOne = new Department(); $oneOne->setName('ONE-DeptOne'); $oneOne->setOffice($this->getReference('officeOne')); $manager->persist($oneOne); $oneTwo = new Department(); $oneTwo->setName('ONE-DeptTwo'); $oneTwo->setOffice($this->getReference('officeOne')); $manager->persist($oneTwo); $oneThree = new Department(); $oneThree->setName('ONE-DeptThree'); $oneThree->setOffice($this->getReference('officeOne')); $manager->persist($oneThree); $twoOne = new Department(); $twoOne->setName('TWO-DeptOne'); $twoOne->setOffice($this->getReference('officeTwo')); $manager->persist($twoOne); $twoTwo = new Department(); $twoTwo->setName('TWO-DeptTwo'); $twoTwo->setOffice($this->getReference('officeTwo')); $manager->persist($twoTwo); $manager->flush(); $aclProvider = $this->container->get('security.acl.provider'); $devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV'); $adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN'); $leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD'); $userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER'); $objectIdentity = ObjectIdentity::fromDomainObject($stepDept); $acl = $aclProvider->createAcl($objectIdentity); $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR); $aclProvider->updateAcl($acl); $objectIdentity = ObjectIdentity::fromDomainObject($oneOne); $acl = $aclProvider->createAcl($objectIdentity); $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR); $aclProvider->updateAcl($acl); $objectIdentity = ObjectIdentity::fromDomainObject($oneTwo); $acl = $aclProvider->createAcl($objectIdentity); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_VIEW); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR); $aclProvider->updateAcl($acl); $objectIdentity = ObjectIdentity::fromDomainObject($oneThree); $acl = $aclProvider->createAcl($objectIdentity); $acl->insertObjectAce($leadRoleSecurityIdentity, MaskBuilder::MASK_VIEW); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR); $aclProvider->updateAcl($acl); $objectIdentity = ObjectIdentity::fromDomainObject($twoOne); $acl = $aclProvider->createAcl($objectIdentity); $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR); $aclProvider->updateAcl($acl); $objectIdentity = ObjectIdentity::fromDomainObject($twoTwo); $acl = $aclProvider->createAcl($objectIdentity); $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW); $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR); $aclProvider->updateAcl($acl); $this->addReference('stepDept', $stepDept); $this->addReference('oneOne', $oneOne); $this->addReference('oneTwo', $oneTwo); $this->addReference('oneThree', $oneThree); $this->addReference('twoOne', $twoOne); $this->addReference('twoTwo', $twoTwo); }