Exemplo n.º 1
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.º 2
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.º 3
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());
 }
Exemplo n.º 4
0
 public function testSetGetUserTwice()
 {
     $user1 = new User();
     $user1->setId(123);
     $this->target->setUser($user1);
     $user2 = new User();
     $user2->setId(456);
     $this->target->setUser($user2);
     $this->assertEquals($this->target->getUser(), $user2);
 }
 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());
 }