File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -1936,8 +1936,8 @@ public function revertTo($revid) {
19361936
19371937 $ values = [
19381938 'id ' => $ this ->getID (),
1939- 'name ' => $ revision ->fields ['name ' ],
1940- 'answer ' => $ revision ->fields ['answer ' ]
1939+ 'name ' => addslashes ( $ revision ->fields ['name ' ]) ,
1940+ 'answer ' => addslashes ( $ revision ->fields ['answer ' ])
19411941 ];
19421942
19431943 if ($ this ->update ($ values )) {
Original file line number Diff line number Diff line change @@ -99,6 +99,49 @@ public function testNewRevision() {
9999 $ where
100100 );
101101 $ this ->integer ((int )$ nb )->isIdenticalTo (2 );
102+
103+ //try a change on contents
104+ $ this ->boolean (
105+ $ kb1 ->update (
106+ [
107+ 'id ' => $ kb1 ->getID (),
108+ 'answer ' => \Toolbox::addslashes_deep ('Don \'t use paths with spaces, like C: \\Program Files \\MyApp ' )
109+ ]
110+ )
111+ )->isTrue ();
112+
113+ $ this ->boolean (
114+ $ kb1 ->update (
115+ [
116+ 'id ' => $ kb1 ->getID (),
117+ 'answer ' => 'Answer changed '
118+ ]
119+ )
120+ )->isTrue ();
121+
122+ $ nb = countElementsInTable (
123+ 'glpi_knowbaseitems_revisions ' ,
124+ $ where
125+ );
126+ $ this ->integer ((int )$ nb )->isIdenticalTo (4 );
127+
128+ $ nrev_id = null ;
129+ $ data = $ DB ->request ([
130+ 'SELECT ' => new \QueryExpression ('MAX(id) AS id ' ),
131+ 'FROM ' => 'glpi_knowbaseitems_revisions '
132+ ])->next ();
133+ $ nrev_id = $ data ['id ' ];
134+
135+ $ this ->boolean ($ kb1 ->getFromDB ($ kb1 ->getID ()))->isTrue ();
136+ $ this ->boolean ($ kb1 ->revertTo ($ nrev_id ))->isTrue ();
137+
138+ $ this ->boolean ($ kb1 ->getFromDB ($ kb1 ->getID ()))->isTrue ();
139+ $ this ->string ($ kb1 ->fields ['answer ' ])->isIdenticalTo ('Don \'t use paths with spaces, like C: \\Program Files \\MyApp ' );
140+
141+ //reset
142+ $ this ->boolean ($ kb1 ->getFromDB ($ kb1 ->getID ()))->isTrue ();
143+ $ this ->boolean ($ kb1 ->revertTo ($ rev_id ))->isTrue ();
144+
102145 }
103146
104147 public function testGetTabNameForItemNotLogged () {
You can’t perform that action at this time.
0 commit comments