Exemplo n.º 1
0
 public function setUp()
 {
     switch ($this->getName(false)) {
         case 'testImplementsListenerAggregateInterface':
             $this->target = $this->getMockBuilder('\\Jobs\\Listener\\MailSender')->disableOriginalConstructor()->getMock();
             break;
         case 'testRequiresMailServiceAndOptionsInConstructorAndSetsInternalProperties':
         case 'testAttachsToAndDetachsFromJobEvents':
             $this->mailServiceMock = $this->getMockBuilder('\\Core\\Mail\\MailService')->disableOriginalConstructor()->getMock();
             $this->targetOptions = array('siteName' => 'TestConstructor', 'adminEmail' => 'test@constructor');
             $this->target = new MailSender($this->mailServiceMock, $this->targetOptions);
             break;
         default:
             $this->mailServiceMock = $this->getMockBuilder('\\Core\\Mail\\MailService')->disableOriginalConstructor()->getMock();
             $this->mailServiceMock->expects($this->atLeastOnce())->method('send')->with($this->callback(array($this, 'popMailMock')));
             $this->mailServiceMock->expects($this->any())->method('get')->with('htmltemplate')->will($this->returnCallback(array($this, 'pushMailMock')));
             $this->targetOptions = array('siteName' => 'Test', 'adminEmail' => 'test@admin');
             $this->target = new MailSender($this->mailServiceMock, $this->targetOptions);
             $user = new User();
             $user->getInfo()->setEmail('test@email');
             $user->getInfo()->setFirstName('TestFirstName');
             $user->getInfo()->setLastName('TestLastName');
             $job = new Job();
             $job->setUser($user);
             $job->setReference('testRef');
             $this->jobEvent = new JobEvent();
             $this->jobEvent->setJobEntity($job);
             $this->inspectMailsCount = 0;
     }
 }
Exemplo n.º 2
0
 public function init()
 {
     if (!$this->job) {
         return false;
     }
     /* @var \Auth\Entity\Info $userInfo */
     $userInfo = $this->user->getInfo();
     $name = $userInfo->getDisplayName();
     if ('' == trim($name)) {
         $name = $userInfo->getEmail();
     }
     $variables = ['name' => $name, 'title' => $this->job->getTitle()];
     $this->setTo($this->user->getInfo()->getEmail(), $this->user->getInfo()->getDisplayName(false));
     $this->setVariables($variables);
     $subject = 'New application for your vacancy "%s"';
     if ($this->isTranslatorEnabled()) {
         $subject = $this->getTranslator()->translate($subject);
     }
     $this->setSubject(sprintf($subject, $this->job->getTitle()));
     /* @var \Applications\Entity\Settings $settings */
     $settings = $this->user->getSettings('Applications');
     $body = $settings->getMailAccessText();
     if ('' == $body) {
         $body = "Hello ##name##,\n\nThere is a new application for your vacancy:\n\"##title##\"\n\n";
         if ($this->isTranslatorEnabled()) {
             $body = $this->getTranslator()->translate($body);
         }
     }
     $this->setBody($body);
     return $this;
 }
Exemplo n.º 3
0
 protected function save()
 {
     $userId = $this->params()->fromPost('userId');
     $org = $this->job->getOrganization();
     if ($org->isHiringOrganization()) {
         $org = $org->getParent();
     }
     /*
      * Maybe we should inject the user repository also, to prevent this
      * rather expensive loop. On the other hand... how often will someone change the job user?
      */
     if ($org->getUser()->getId() == $userId) {
         $this->job->setUser($org->getUser());
     } else {
         /* @var \Organizations\Entity\Employee  $emp */
         foreach ($org->getEmployees() as $emp) {
             $user = $emp->getUser();
             if ($user->getId() == $userId) {
                 $this->job->setUser($user);
             }
         }
     }
     $model = new JsonModel(array('success' => true));
     return $model;
 }
Exemplo n.º 4
0
 public function provideInjectOrganizationTestData()
 {
     $org = new Organization();
     $org->setId('alreadyHereOrg');
     $job = new Job();
     $job->setOrganization($org);
     return array(array(new \stdClass(), 'default'), array($job, 'default'), array(new Job(), 'one'), array(new Job(), 'more'));
 }
Exemplo n.º 5
0
 /**
  * @covers Applications\Entity\Application::getJob
  * @covers Applications\Entity\Application::setJob
  */
 public function testSetGetJob()
 {
     $user = new User();
     $user->setId(123);
     $job = new Job();
     $job->setUser($user);
     $this->target->setJob($job);
     $this->assertEquals($job, $this->target->getJob());
 }
 /**
  * Sets the organizations contact address
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 protected function setOrganizationInfo()
 {
     if (!isset($this->job)) {
         throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job');
     }
     $organizationName = '';
     $organizationStreet = '';
     $organizationPostalCode = '';
     $organizationPostalCity = '';
     $organization = $this->job->organization;
     $user = $this->job->getUser();
     if (isset($organization)) {
         $organizationName = $organization->organizationName->name;
         $organizationStreet = $organization->contact->street . ' ' . $organization->contact->houseNumber;
         $organizationPostalCode = $organization->contact->postalcode;
         $organizationPostalCity = $organization->contact->city;
         $organizationPhone = $organization->contact->phone;
         $organizationFax = $organization->contact->fax;
     } else {
         $organizationName = $organizationStreet = $organizationPostalCode = $organizationPostalCity = $organizationPhone = $organizationFax = '';
     }
     $this->container['contactEmail'] = $user ? $user->getInfo()->getEmail() : '';
     $this->container['organizationName'] = $organizationName;
     $this->container['street'] = $organizationStreet;
     $this->container['postalCode'] = $organizationPostalCode;
     $this->container['city'] = $organizationPostalCity;
     $this->container['phone'] = $organizationPhone;
     $this->container['fax'] = $organizationFax;
     if (isset($organization) && isset($organization->image) && $organization->image->uri) {
         $this->container['uriLogo'] = $this->makeAbsolutePath($organization->image->uri);
     } else {
         $this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo);
     }
     return $this;
 }
Exemplo n.º 7
0
 /**
  * @param array $params
  *
  * @return Job
  */
 public static function createEntityWithRandomData(array $params = array())
 {
     $params = static::createNewRelations($params);
     $withId = true;
     $entityId = bin2hex(substr(uniqid(), 1));
     // define here another variables
     extract($params);
     $entity = new Job();
     // here set another variables
     if (isset($organization)) {
         $entity->setOrganization($organization);
     }
     if ($withId) {
         $entity->setId($entityId);
     }
     return $entity;
 }
 /**
  * @return $this
  * @throws \InvalidArgumentException
  */
 protected function setLocation()
 {
     if (!isset($this->job)) {
         throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job');
     }
     $location = $this->job->getLocation();
     $this->container['location'] = isset($location) ? $location : '';
     return $this;
 }
Exemplo n.º 9
0
 public function __invoke(Job $jobEntity)
 {
     $ats = $jobEntity->getAtsMode();
     if ($ats->isDisabled()) {
         return '';
     }
     if ($ats->isIntern() || $ats->isEmail()) {
         $urlHelper = $this->urlHelper;
         $serverUrlHelper = $this->serverUrlHelper;
         $params = $this->paramsHelper;
         $query = array('subscriberUri' => $serverUrlHelper(array()) . '/subscriber/' . 1);
         $route = 'lang/apply';
         $params = array('applyId' => $jobEntity->getApplyId(), 'lang' => $params('lang'));
         $url = $urlHelper($route, $params, array('query' => $query));
     } else {
         $url = $ats->getUri();
     }
     $translate = $this->translateHelper;
     $result = sprintf('<a href="%s">%s</a>', $url, $translate('Apply'));
     return $result;
 }
Exemplo n.º 10
0
 protected function initJob()
 {
     $repo = $this->repository;
     $organization = $this->organization;
     for ($i = 1; $i <= 5; $i++) {
         $title = 'Job Repository Test ' . $i;
         $job = $repo->findOneBy(array('title' => $title));
         if (!$job) {
             $job = new Job();
             $job->setTitle($title);
             $job->setStatus(Status::ACTIVE);
             $job->setIsDraft(false);
             $job->setOrganization($organization);
             $this->dm->persist($job);
             $this->dm->flush($job);
         }
         $this->jobs[] = $job;
     }
     $title = 'Job Repository Test Draft';
     $job = $repo->findOneBy(array('title' => $title));
     if (!$job instanceof Job) {
         $job = new Job();
         $job->setTitle($title);
         $job->setIsDraft(true);
         $job->setStatus(Status::CREATED);
         $job->setOrganization($organization);
         $this->dm->persist($job);
         $this->dm->flush($job);
     }
 }
Exemplo n.º 11
0
 /**
  * Test branja metapodatkov iz anotacij taska
  *
  *
  */
 public function testGetTaskMeta(\UnitTester $I)
 {
     $jobId = $this->job->getId();
     $em = $I->grabEntityManager();
     $em->clear();
     $jm = $this->getJobManager($I);
     $job = $jm->find($jobId);
     $meta = $jm->getTaskMeta($job);
     $I->assertTrue($meta instanceof \Jobs\Annotation\Task\Meta);
     $I->assertEquals($meta->name, "dummy task");
     $I->assertEquals($meta->acl, "test.acl.xx");
     $em->remove($job);
     $em->flush();
     $job = $jm->find($jobId);
     $I->assertEmpty($job);
 }
 /**
  * assign the form-elements to the template
  * @param \Jobs\Entity\Job $job
  * @return $this
  */
 protected function extract($job)
 {
     $this->job = $job;
     $this->setApplyData();
     $this->setOrganizationInfo();
     $this->setLocation();
     $this->setDescription();
     $this->setTemplate();
     $this->setTemplateDefaultValues();
     $this->container['descriptionEditable'] = $job->getTemplateValues()->getDescription();
     $this->container['benefits'] = $job->getTemplateValues()->getBenefits();
     $this->container['requirements'] = $job->getTemplateValues()->getRequirements();
     $this->container['qualifications'] = $job->getTemplateValues()->getQualifications();
     $this->container['title'] = $job->getTemplateValues()->getTitle();
     $this->container['headTitle'] = strip_tags($job->getTemplateValues()->getTitle());
     $this->container['uriApply'] = $this->container['applyData']['uri'];
     $this->container['contactEmail'] = strip_tags($job->getContactEmail());
     return $this;
 }
Exemplo n.º 13
0
 public function testMakeSnapshot()
 {
     $this->assertEquals($this->target->makeSnapshot(), new JobSnapshot($this->target));
 }
Exemplo n.º 14
0
 public function testFinishReport()
 {
     // naredim task
     $job = new Job();
     $job->setData(['id' => 'XXXX', 'toPrinter' => 'e9e018ad-d913-4a96-8509-ea41fa82e30a'])->setName('Testni izpis')->setTask('TestAssets\\Report\\DocumentTestReport');
     $task = new DokumentTestReport($job, $this->em);
     $task->setServiceLocator($this->sm);
     $this->mockmPdfPrinter();
     $task->printOut('<html><body>prvidokument</body></html>');
     $task->printOut('<html><body>drugidokument</body></html>');
     $task->checkData();
     $error = $task->finishReport('Testni Izpis');
     $this->assertEquals("", $error, 'ni napake');
 }
 public function testCopyAttachments()
 {
     $applicationAttachment1Data = ['getContent' => 'content', 'getName' => 'name', 'getType' => 'type', 'getDateUploaded' => new \DateTime()];
     $applicationAttachment1 = $this->getMockBuilder(ApplicationAttachment::class)->setMethods(array_keys($applicationAttachment1Data))->getMock();
     foreach ($applicationAttachment1Data as $method => $return) {
         $applicationAttachment1->expects($this->once())->method($method)->willReturn($return);
     }
     $applicationAttachments = new ArrayCollection([$applicationAttachment1]);
     $this->repository->expects($this->once())->method('create');
     $job = new Job();
     $user = new User();
     $user->setId('jobUser');
     $job->setUser($user);
     $application = $this->getMockBuilder(Application::class)->setMethods(['getContact', 'getAttachments'])->getMock();
     $application->method('getContact')->willReturn(new ApplicationContact());
     $application->expects($this->once())->method('getAttachments')->willReturn($applicationAttachments);
     $application->setJob($job);
     $cv = $this->repository->createFromApplication($application, $this->user);
     $this->assertSame($this->cv, $cv);
     $cvAttachments = $cv->getAttachments();
     $this->assertSame($applicationAttachments->count(), $cvAttachments->count());
     $cvAttachment1 = $cvAttachments->first();
     $this->assertInstanceOf(CvAttachment::class, $cvAttachment1);
     $this->assertSame($applicationAttachment1Data['getContent'], $cvAttachment1->getFile()->getBytes());
     $this->assertSame($applicationAttachment1Data['getName'], $cvAttachment1->getName());
     $this->assertSame($applicationAttachment1Data['getType'], $cvAttachment1->getType());
     $this->assertSame($applicationAttachment1Data['getDateUploaded'], $cvAttachment1->getDateUploaded());
     $this->assertSame($user, $cvAttachment1->getUser());
 }
Exemplo n.º 16
0
 /**
  * @param Job $job
  * @return array
  */
 public function dehydrate(Job $job)
 {
     return array('title' => $job->getTitle(), 'location' => $job->getLocation(), 'link' => $this->url->__invoke('lang/jobs/view', [], ['query' => ['id' => $job->getId()], 'force_canonical' => true]), 'organization' => array('name' => $job->getOrganization()->getOrganizationName()->getName()), 'template_values' => array('requirements' => $job->getTemplateValues()->getRequirements(), 'qualification' => $job->getTemplateValues()->getQualifications(), 'benefits' => $job->getTemplateValues()->getBenefits()));
 }
Exemplo n.º 17
0
 /**
  * Sends a job event related mail
  *
  * @param Job    $job
  * @param string $template
  * @param string $subject
  * @param bool   $adminMail if true, the mail is send to the administrator instead of to the user.
  */
 protected function sendMail(Job $job, $template, $subject, $adminMail = false)
 {
     $mail = $this->mailer->get('htmltemplate');
     $mail->setTemplate($template)->setSubject($subject)->setVariables(array('job' => $job, 'siteName' => $this->options['siteName']));
     if ($adminMail) {
         $mail->setTo($this->options['adminEmail']);
     } else {
         $user = $job->getUser();
         $userInfo = $user->getInfo();
         $userEmail = $userInfo->getEmail();
         $userName = $userInfo->getDisplayName(false);
         $mail->setTo($userEmail, $userName);
     }
     $this->mailer->send($mail);
 }
Exemplo n.º 18
0
 /**
  * @testdox Allows setting the status of a job posting
  * @covers Jobs\Entity\Job::getTemplate
  * @covers Jobs\Entity\Job::setTemplate
  * @dataProvider provideIsActiveTestData
  */
 public function testIsActive($isDraft, $status, $expected)
 {
     $this->target->setIsDraft($isDraft);
     $this->target->setStatus($status);
     $this->assertEquals($expected, $this->target->isActive());
 }