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
58
58
*
59
59
* @param string $changeType
60
60
* @param string $author
61
- * @param null|int|\DateTime $date
61
+ * @param null|int|bool| \DateTime $date
62
62
*/
63
63
public function __construct ($ changeType = null , $ author = null , $ date = null )
64
64
{
65
65
$ this ->changeType = $ changeType ;
66
66
$ this ->author = $ author ;
67
- if ($ date !== null ) {
67
+ if ($ date !== null && $ date !== false ) {
68
68
$ this ->date = ($ date instanceof \DateTime) ? $ date : new \DateTime ('@ ' . $ date );
69
69
}
70
70
}
Original file line number Diff line number Diff line change @@ -41,4 +41,22 @@ public function testConstructDefault()
41
41
$ this ->assertEquals ($ date , $ oTrackChange ->getDate ());
42
42
$ this ->assertEquals (TrackChange::INSERTED , $ oTrackChange ->getChangeType ());
43
43
}
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
+ }
44
62
}
You can’t perform that action at this time.
0 commit comments