File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,13 @@ class TrackChange extends AbstractContainer
5858 *
5959 * @param string $changeType
6060 * @param string $author
61- * @param null|int|\DateTime $date
61+ * @param null|int|bool| \DateTime $date
6262 */
6363 public function __construct ($ changeType = null , $ author = null , $ date = null )
6464 {
6565 $ this ->changeType = $ changeType ;
6666 $ this ->author = $ author ;
67- if ($ date !== null ) {
67+ if ($ date !== null && $ date !== false ) {
6868 $ this ->date = ($ date instanceof \DateTime) ? $ date : new \DateTime ('@ ' . $ date );
6969 }
7070 }
Original file line number Diff line number Diff line change @@ -41,4 +41,22 @@ public function testConstructDefault()
4141 $ this ->assertEquals ($ date , $ oTrackChange ->getDate ());
4242 $ this ->assertEquals (TrackChange::INSERTED , $ oTrackChange ->getChangeType ());
4343 }
44+
45+ /**
46+ * New instance with invalid \DateTime (produced by \DateTime::createFromFormat(...))
47+ */
48+ public function testConstructDefaultWithInvalidDate ()
49+ {
50+ $ author = 'Test User ' ;
51+ $ date = false ;
52+ $ oTrackChange = new TrackChange (TrackChange::INSERTED , $ author , $ date );
53+
54+ $ oText = new Text ('dummy text ' );
55+ $ oText ->setTrackChange ($ oTrackChange );
56+
57+ $ this ->assertInstanceOf ('PhpOffice \\PhpWord \\Element \\TrackChange ' , $ oTrackChange );
58+ $ this ->assertEquals ($ author , $ oTrackChange ->getAuthor ());
59+ $ this ->assertEquals ($ date , null );
60+ $ this ->assertEquals (TrackChange::INSERTED , $ oTrackChange ->getChangeType ());
61+ }
4462}
You can’t perform that action at this time.
0 commit comments