File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
src/Symfony/Component/Stopwatch Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class Stopwatch
30
30
31
31
public function __construct ()
32
32
{
33
- $ this ->sections = $ this -> activeSections = array ( ' __root__ ' => new Section ( ' __root__ ' ) );
33
+ $ this ->reset ( );
34
34
}
35
35
36
36
/**
@@ -156,4 +156,12 @@ public function getSectionEvents($id)
156
156
{
157
157
return isset ($ this ->sections [$ id ]) ? $ this ->sections [$ id ]->getEvents () : array ();
158
158
}
159
+
160
+ /**
161
+ * Resets the stopwatch to its original state.
162
+ */
163
+ public function reset ()
164
+ {
165
+ $ this ->sections = $ this ->activeSections = array ('__root__ ' => new Section ('__root__ ' ));
166
+ }
159
167
}
Original file line number Diff line number Diff line change @@ -153,4 +153,16 @@ public function testReopenANewSectionShouldThrowAnException()
153
153
$ stopwatch = new Stopwatch ();
154
154
$ stopwatch ->openSection ('section ' );
155
155
}
156
+
157
+ public function testReset ()
158
+ {
159
+ $ stopwatch = new Stopwatch ();
160
+
161
+ $ stopwatch ->openSection ();
162
+ $ stopwatch ->start ('foo ' , 'cat ' );
163
+
164
+ $ stopwatch ->reset ();
165
+
166
+ $ this ->assertEquals (new Stopwatch (), $ stopwatch );
167
+ }
156
168
}
You can’t perform that action at this time.
0 commit comments