public function testGetFilesAppendsContactImage()
 {
     $document = new Cv();
     $contact = $this->getMockBuilder(Contact::class)->disableOriginalConstructor()->setMethods(['getImage'])->getMock();
     $image = $this->getMockBuilder(ContactImage::class)->disableOriginalConstructor()->getMock();
     $contact->expects($this->once())->method('getImage')->willReturn($image);
     $document->setContact($contact);
     $args = $this->getMockBuilder(OnFlushEventArgs::class)->disableOriginalConstructor()->getMock();
     $this->target->__document__ = $document;
     $actual = $this->target->onFlush($args);
     $this->assertEquals($image, array_pop($actual));
 }
Beispiel #2
0
 public function testFindByDraft()
 {
     $this->removeCvData();
     /* @var $dm \Doctrine\ODM\MongoDB\DocumentManager */
     $dm = $this->serviceLocator->get('doctrine.documentmanager.odm_default');
     $user = $this->activeUser;
     $repo = $dm->getRepository('Cv\\Entity\\Cv');
     $cv = new Cv();
     $cv->setUser($user)->setIsDraft(true);
     $dm->persist($cv);
     $dm->flush($cv);
     $this->assertInstanceOf(Cv::class, $repo->findDraft($user));
 }
 public function testCopyContact()
 {
     // expect proper setting of user to application contact
     $applicationContactImage = $this->getMockBuilder(ApplicationAttachment::class)->getMock();
     // expect calling of application contact getImage() method
     $applicationContact = $this->getMockBuilder(ApplicationContact::class)->getMock();
     $job = new Job();
     $user = new User();
     $user->setId('jobUser');
     $job->setUser($user);
     // expect calling of application getContact() method
     $application = $this->getMockBuilder(Application::class)->setMethods(['getContact'])->getMock();
     $application->expects($this->once())->method('getContact')->willReturn($applicationContact);
     $application->setJob($job);
     // expect proper setting of contact to CV
     $this->cv->expects($this->once())->method('setContact')->with($this->equalTo($applicationContact));
     $cv = $this->repository->createFromApplication($application, $this->user);
     $this->assertSame($this->cv, $cv);
 }
 private function validateCv(Cv $cv)
 {
     if ($cv->getContact()->getEmail() && $cv->getPreferredJob()->getDesiredJob() && count($cv->getPreferredJob()->getDesiredLocations())) {
         $cv->setIsDraft(false);
     }
 }