public function setUp()
 {
     $this->target = new HiringOrganizationSelectFactory();
     if ("testImplementsFactoryInterface" == $this->getName(false)) {
         return;
     }
     $userOrg = $this->getMockBuilder('\\Organizations\\Entity\\OrganizationReference')->disableOriginalConstructor()->getMock();
     $user = new User();
     $user->setId('testUser');
     $user->setOrganization($userOrg);
     $this->user = $user;
     $auth = $this->getMockBuilder('Auth\\AuthenticationService')->disableOriginalConstructor()->getMock();
     $auth->expects($this->once())->method('getUser')->willReturn($user);
     $headscript = $this->getMockBuilder('\\Zend\\View\\Helper\\HeadScript')->disableOriginalConstructor()->getMock();
     $headscript->expects($this->once())->method('__call')->with('appendFile', array('Jobs/js/form.hiring-organization-select.js'));
     $basepath = $this->getMockBuilder('\\Zend\\View\\Helper\\BasePath')->disableOriginalConstructor()->getMock();
     $basepath->expects($this->once())->method('__invoke')->with('Jobs/js/form.hiring-organization-select.js')->will($this->returnArgument(0));
     $helper = $this->getMockBuilder('\\Zend\\View\\HelperPluginManager')->disableOriginalConstructor()->getMock();
     $helper->expects($this->exactly(2))->method('get')->withConsecutive(array('headscript'), array('basepath'))->will($this->onConsecutiveCalls($headscript, $basepath));
     $services = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceManager')->disableOriginalConstructor()->getMock();
     $services->expects($this->exactly(2))->method('get')->withConsecutive(array('AuthenticationService'), array('ViewHelperManager'))->will($this->onConsecutiveCalls($auth, $helper));
     $formElements = $this->getMockBuilder('\\Zend\\Form\\FormElementManager')->disableOriginalConstructor()->getMock();
     $formElements->expects($this->once())->method('getServiceLocator')->willReturn($services);
     $this->formElements = $formElements;
 }
 public function setUp()
 {
     $this->target = new HiringOrganizationSelectFactory();
     if ("testImplementsFactoryInterface" == $this->getName(false)) {
         return;
     }
     $userOrg = $this->getMockBuilder('\\Organizations\\Entity\\OrganizationReference')->disableOriginalConstructor()->getMock();
     $user = new User();
     $user->setId('testUser');
     $user->setOrganization($userOrg);
     $this->user = $user;
     $auth = $this->getMockBuilder('Auth\\AuthenticationService')->disableOriginalConstructor()->getMock();
     $auth->expects($this->once())->method('getUser')->willReturn($user);
     $services = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceManager')->disableOriginalConstructor()->getMock();
     $services->expects($this->once())->method('get')->with('AuthenticationService')->willReturn($auth);
     $formElements = $this->getMockBuilder('\\Zend\\Form\\FormElementManager')->disableOriginalConstructor()->getMock();
     $formElements->expects($this->once())->method('getServiceLocator')->willReturn($services);
     $this->formElements = $formElements;
 }
Пример #3
0
 /**
  * @param array $params
  *
  * @return User
  */
 public static function createEntityWithRandomData(array $params = array())
 {
     $withId = true;
     $entityId = bin2hex(substr(uniqid(), 1));
     $email = uniqid('email');
     $login = uniqid('login');
     $password = uniqid('password');
     $role = User::ROLE_RECRUITER;
     extract($params);
     $userEntity = new User();
     $userEntity->setEmail($email)->setLogin($login)->setPassword($password)->setRole($role);
     $infoEntity = new Info();
     $infoEntity->setEmail($email);
     $userEntity->setInfo($infoEntity);
     if ($withId) {
         $userEntity->setId($entityId);
     }
     $organization = new OrganizationReferenceMock();
     $userEntity->setOrganization($organization);
     return $userEntity;
 }
 /**
  * @testdox Creates a proper configured HTMLTemplate Mail.
  */
 public function testCreateService()
 {
     $user = new User();
     $user->setId('testUser');
     $user->setEmail('test@user');
     $options = array('token' => 'testToken', 'user' => $user, 'template' => 'testTemplate');
     $ownerOrg = new Organization();
     $ownerOrg->setId('ownerOrg');
     $ownerOrgName = new OrganizationName('TestOwnerOrg');
     $ownerOrg->setOrganizationName($ownerOrgName);
     $userOrg = new Organization();
     $userOrg->setId('userOrg');
     $userOrgName = new OrganizationName('TestUserOrg');
     $userOrg->setOrganizationName($userOrgName);
     $orgRep = $this->getMockBuilder('\\Organizations\\Repository\\Organization')->disableOriginalConstructor()->getMock();
     $orgRep->expects($this->exactly(2))->method('findByUser')->withConsecutive(array('testOwner'), array('testUser'))->will($this->onConsecutiveCalls($ownerOrg, $userOrg));
     $ownerOrgRef = new OrganizationReference('testOwner', $orgRep);
     $userOrgRef = new OrganizationReference('testUser', $orgRep);
     $user->setOrganization($userOrgRef);
     $owner = new User();
     $owner->getInfo()->setFirstName('Test')->setLastName('Owner');
     $owner->setOrganization($ownerOrgRef);
     $authService = $this->getMockBuilder('\\Auth\\AuthenticationService')->disableOriginalConstructor()->getMock();
     $authService->expects($this->once())->method('getUser')->willReturn($owner);
     $router = $this->getMockForAbstractClass('\\Zend\\Mvc\\Router\\RouteStackInterface');
     $router->expects($this->once())->method('assemble')->with(array('action' => 'accept'), array('name' => 'lang/organizations/invite', 'query' => array('token' => $options['token'], 'organization' => $ownerOrg->getId())))->willReturn('testUrl');
     $services = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceManager')->disableOriginalConstructor()->getMock();
     $services->expects($this->exactly(2))->method('get')->withConsecutive(array('AuthenticationService'), array('Router'))->will($this->onConsecutiveCalls($authService, $router));
     $mailService = $this->getMockBuilder('\\Core\\Mail\\MailService')->disableOriginalConstructor()->getMock();
     $mailService->expects($this->once())->method('getServiceLocator')->willReturn($services);
     $mailMock = new HTMLTemplateMessage();
     $translator = $this->getMockBuilder('\\Zend\\I18n\\Translator\\Translator')->disableOriginalConstructor()->getMock();
     $translator->expects($this->any())->method('translate')->will($this->returnArgument(0));
     $mailMock->setTranslator($translator);
     $mailService->expects($this->once())->method('get')->with('htmltemplate')->willReturn($mailMock);
     $target = new EmployeeInvitationFactory();
     $target->setCreationOptions($options);
     $mail = $target->createService($mailService);
     $vars = $mail->getVariables()->getArrayCopy();
     $expected = array('inviter' => 'Test Owner', 'organization' => 'TestOwnerOrg', 'token' => $options['token'], 'user' => '', 'hasAssociation' => true, 'url' => 'testUrl', 'isOwner' => true, 'currentOrganization' => 'TestUserOrg', 'template' => 'testTemplate');
     $this->assertEquals($expected, $vars);
     $this->assertEquals($user->getEmail(), $mail->getTo()->current()->getEmail());
 }
 /**
  * Gets an Assertion event seeded with Mock objects.
  *
  * @param bool $isOneEmployeeAllowed if true, one employee in the employees collection gets job create permissions.
  *
  * @return AssertionEvent
  */
 protected function getTestEvent($isOneEmployeeAllowed = true)
 {
     $employees = new ArrayCollection();
     for ($i = 0; $i < 3; $i++) {
         $empUser = new User();
         $empUser->setId('1234-' . $i);
         $perm = new EmployeePermissions(EmployeePermissionsInterface::JOBS_VIEW);
         if (2 == $i && $isOneEmployeeAllowed) {
             $perm->grant(EmployeePermissionsInterface::JOBS_CREATE);
         }
         $emp = new Employee($empUser, $perm);
         $employees->add($emp);
     }
     $org = $this->getMockBuilder('\\Organizations\\Entity\\OrganizationReference')->disableOriginalConstructor()->getMock();
     $org->expects($this->once())->method('hasAssociation')->willReturn(true);
     $org->expects($this->once())->method('isOwner')->willReturn(false);
     $org->expects($this->once())->method('getEmployees')->willReturn($employees);
     $role = new User();
     $role->setId('1234-2');
     $role->setOrganization($org);
     $e = new AssertionEvent();
     $e->setRole($role);
     return $e;
 }