public function testSetCreatedTimeStringWithEmpty()
 {
     $expected = new \DateTime();
     $this->assertEmpty($this->getCreatedTimeString());
     $this->setCreatedTimeString(null);
     $this->assertEquals($this->getCreatedTimeString(), $expected->format(DateFormat::getDateTimeFormat()));
 }
 /**
  * @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'));
 }
 public function testCreateDateTimeFromMysql()
 {
     $expected = '01/05/1978 00:00:00';
     $mysqlTest = '1978-05-01 00:00:00';
     $this->assertTrue(OPGDateFormat::createDateTime($mysqlTest) instanceof \DateTime);
     $this->assertEquals($expected, OPGDateFormat::createDateTime($mysqlTest)->format(OPGDateFormat::getDateTimeFormat()));
 }
 /**
  * @return string
  */
 public function getCreatedTimeString()
 {
     if (!empty($this->createdTime)) {
         return $this->createdTime->format(OPGDateFormat::getDateTimeFormat());
     }
     return '';
 }
 /**
  * @param      $propertyName
  * @param bool $includeTime
  * @return string
  */
 protected function getFormattedDateTime($propertyName, $includeTime = false)
 {
     if (property_exists(get_class($this), $propertyName) && isset($this->{$propertyName}) && $this->{$propertyName} instanceof \DateTime) {
         if (true === $includeTime) {
             return $this->{$propertyName}->format(OPGDateFormat::getDateTimeFormat());
         } else {
             return $this->{$propertyName}->format(OPGDateFormat::getDateFormat());
         }
     }
     return '';
 }
 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 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 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 testGetSetCreatedOnString()
 {
     $expected = date(OPGDateFormat::getDateTimeFormat());
     $this->event->setCreatedOnString($expected);
     $this->assertEquals($expected, $this->event->getCreatedOnString());
 }