/**
  * @param string $createdTime
  *
  * @return $this
  */
 public function setCreatedTimeString($createdTime)
 {
     if (empty($createdTime)) {
         return $this->setCreatedTime();
     }
     return $this->setCreatedTime(OPGDateFormat::createDateTime($createdTime));
 }
 /**
  * @expectedException \Exception
  */
 public function testNonMatchingMethodDoesNothing()
 {
     $today = (new \DateTime())->format(DateFormat::getDateTimeFormat());
     $this->assertTrue($this->stub->setTodaysDate($today) instanceof HasDateTimeAccessor);
     $this->assertEmpty($this->stub->getDateTimeAsString('todaysDate'));
     $this->assertEmpty($this->stub->getDateAsString('todaysDate'));
 }
 /**
  * @param $value
  * @param $propertyName
  * @return HasDateTimeAccessor
  */
 public function setDateTimeFromString($value, $propertyName)
 {
     if (property_exists(get_class($this), $propertyName) && !empty($value)) {
         $this->{$propertyName} = OPGDateFormat::createDateTime($value);
     }
     return $this;
 }
 public function testSetCreatedTimeStringWithEmpty()
 {
     $expected = new \DateTime();
     $this->assertEmpty($this->getCreatedTimeString());
     $this->setCreatedTimeString(null);
     $this->assertEquals($this->getCreatedTimeString(), $expected->format(DateFormat::getDateTimeFormat()));
 }
 public function testGetSetDateAdded()
 {
     $expected = DateFormat::createDateTime('01/01/2014 00:00:01');
     $now = new \DateTime();
     $this->assertEquals($now, $this->warning->getDateAdded());
     $this->assertEquals($expected, $this->warning->setDateAdded($expected)->getDateAdded());
 }
 public function testGetSetCreatedDateEmptyString()
 {
     $expectedDate = new \DateTime();
     $this->correspondence->setDateTimeFromString(null, 'createdDate');
     $returnedDate = $this->correspondence->getCreatedDate();
     $this->assertEquals($expectedDate->format(OPGDateFormat::getDateTimeFormat()), $returnedDate->format(OPGDateFormat::getDateTimeFormat()));
 }
 public function testCreateDateTimeFromBanktec()
 {
     $expected = date('dmY');
     $this->assertTrue(OPGDateFormat::createDateTime($expected) instanceof \DateTime);
     $this->assertEquals($expected, OPGDateFormat::createDateTime($expected)->format(OPGDateFormat::getBanktecFormat()));
 }
 public function testGetsetNoticeGivenDateValidString()
 {
     $expected = date(OPGDateFormat::getDateFormat());
     $this->na->setNoticeGivenDateString($expected);
     $this->assertEquals($expected, $this->na->getNoticeGivenDateString());
 }
 public function testGetSetCompletedDateEmptyString()
 {
     $this->assertEmpty($this->task->getDateAsString('completedDate'));
     $expectedDate = new \DateTime();
     $this->task->setDefaultDateFromString('', 'completedDate');
     $returnedDate = $this->task->getCompletedDate();
     $this->assertEquals($expectedDate->format(OPGDateFormat::getDateTimeFormat()), $returnedDate->format(OPGDateFormat::getDateTimeFormat()));
 }
 public function testSetGetNotifiedDateString()
 {
     $expected = date(OPGDateFormat::getDateFormat());
     $this->attorney->setLpaPartCSignatureDateString($expected);
     $this->assertEquals($expected, $this->attorney->getLpaPartCSignatureDateString());
 }
 public function testGetSetCreatedOnString()
 {
     $expected = date(OPGDateFormat::getDateTimeFormat());
     $this->event->setCreatedOnString($expected);
     $this->assertEquals($expected, $this->event->getCreatedOnString());
 }
 /**
  * @return string
  */
 public function getDateOfDeathString()
 {
     if (!empty($this->dateOfDeath)) {
         return $this->dateOfDeath->format(OPGDateFormat::getDateFormat());
     }
     return '';
 }
 /**
  * @expectedException \Opg\Common\Model\Entity\Exception\InvalidDateFormatException
  */
 public function testGetSetPaymentDate()
 {
     $expectedDateTime = new \DateTime();
     $expectedDateTimeString = $expectedDateTime->format(DateFormat::getDateFormat());
     $this->assertNull($this->paymentType->getPaymentDate());
     $this->assertEmpty($this->paymentType->getDateAsString('paymentDate'));
     $this->assertEquals($expectedDateTime, $this->paymentType->setPaymentDate($expectedDateTime)->getPaymentDate());
     $this->assertEquals($expectedDateTimeString, $this->paymentType->setDateFromString($expectedDateTimeString, 'paymentDate')->getDateAsString('paymentDate'));
     $this->paymentType->setDateFromString('Last thursday around 3pm', 'paymentDate');
 }
 public function testGetSetSigningOnBehalfDate()
 {
     $expectedDate = new \DateTime();
     $expectedDateString = $expectedDate->format(OPGDateFormat::getDateFormat());
     $this->assertTrue($this->poa->setSigningOnBehalfDate() instanceof PowerOfAttorney);
     $this->assertEmpty($this->poa->getSigningOnBehalfDate());
     $this->assertTrue($this->poa->setSigningOnBehalfDateString('') instanceof PowerOfAttorney);
     $this->assertEmpty($this->poa->getSigningOnBehalfDateString());
     $this->assertTrue($this->poa->setSigningOnBehalfDate($expectedDate) instanceof PowerOfAttorney);
     $this->assertEquals($expectedDate, $this->poa->getSigningOnBehalfDate());
     $this->assertEquals($expectedDateString, $this->poa->getSigningOnBehalfDateString());
     $this->assertTrue($this->poa->setSigningOnBehalfDateString($expectedDateString) instanceof PowerOfAttorney);
     $this->assertEquals($expectedDateString, $this->poa->getSigningOnBehalfDateString());
 }
 /**
  * @return string
  */
 public function getDateClosedString()
 {
     if (!empty($this->dateClosed)) {
         return $this->getDateClosed()->format(DateFormat::getDateFormat());
     }
     return '';
 }
 public function testGetCreatedDate()
 {
     $expected = '01/01/2014 00:00:00';
     $expectedDate = \DateTime::createFromFormat(DateFormat::getDateTimeFormat(), $expected);
     $this->assertTrue($this->document->setCreatedDate($expectedDate) instanceof Document);
     $this->assertEquals($expectedDate, $this->document->getCreatedDate());
     $this->assertEquals($expected, $this->document->getDateTimeAsString('createdDate'));
 }
 public function testSetGetNotifiedDateString()
 {
     $expected = date(OPGDateFormat::getDateFormat());
     $this->notifiedPerson->setDateFromString($expected, 'noticeGivenDate');
     $this->assertEquals($expected, $this->notifiedPerson->getDateAsString('noticeGivenDate'));
 }
 /**
  * @return string
  */
 public function getCreatedOnString()
 {
     if (!empty($this->createdOn)) {
         return $this->createdOn->format(OPGDateFormat::getDateTimeFormat());
     }
     return '';
 }
 /**
  * @return string
  */
 public function getLifeSustainingTreatmentSignatureDateBString()
 {
     if (!empty($this->lifeSustainingTreatmentSignatureDateB)) {
         return $this->lifeSustainingTreatmentSignatureDateB->format(OPGDateFormat::getDateFormat());
     }
     return '';
 }
 public function testGetSetRejectedDateString()
 {
     $expected = (new \DateTime())->format(OPGDateFormat::getDateFormat()) . ' 00:00:01';
     $mock = $this->getMockedClass();
     $this->assertEmpty($mock->getDateAsString('rejectedDate'));
     $this->assertTrue($mock->setDateFromString('', 'rejectedDate') instanceof CaseItem);
     $this->assertEmpty($mock->getDateAsString('rejectedDate'));
     $this->assertTrue($mock->setDateFromString($expected, 'rejectedDate') instanceof CaseItem);
     $this->assertEquals($expected, $mock->getDateTimeAsString('rejectedDate'));
 }
 public function testGetSetDateOfDeathValidString()
 {
     $expected = date(OPGDateFormat::getDateFormat());
     $this->person->setDateOfDeathString($expected);
     $this->assertEquals($expected, $this->person->getDateOfDeathString());
 }
 public function testGetSetEpaDonorNoticeGivenDateFromString()
 {
     $expected = date(OPGDateFormat::getDateFormat());
     $this->assertEmpty($this->epa->getDateAsString('epaDonorNoticeGivenDate'));
     $this->epa->setdateFromString($expected, 'epaDonorNoticeGivenDate');
     $this->assertEquals($expected, $this->epa->getDateAsString('epaDonorNoticeGivenDate'));
 }
 /**
  * @param \DateTime $activeDate
  *
  * @return Task
  */
 public function setActiveDate(\DateTime $activeDate = null)
 {
     if (is_null($activeDate)) {
         $activeDate = OPGDateFormat::createDateTime(date(OPGDateFormat::getDateFormat() . ' 00:00:00'));
     }
     $this->activeDate = $activeDate;
     return $this;
 }