Skip to content

Commit 6ee0022

Browse files
committed
Reset profiler.
1 parent cf2ed15 commit 6ee0022

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

Extension/DataCollector/FormDataCollector.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
7272
public function __construct(FormDataExtractorInterface $dataExtractor)
7373
{
7474
$this->dataExtractor = $dataExtractor;
75-
$this->data = array(
76-
'forms' => array(),
77-
'forms_by_hash' => array(),
78-
'nb_errors' => 0,
79-
);
8075
$this->hasVarDumper = class_exists(ClassStub::class);
76+
77+
$this->reset();
8178
}
8279

8380
/**
@@ -87,6 +84,15 @@ public function collect(Request $request, Response $response, \Exception $except
8784
{
8885
}
8986

87+
public function reset()
88+
{
89+
$this->data = array(
90+
'forms' => array(),
91+
'forms_by_hash' => array(),
92+
'nb_errors' => 0,
93+
);
94+
}
95+
9096
/**
9197
* {@inheritdoc}
9298
*/

Tests/Extension/DataCollector/FormDataCollectorTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,36 @@ public function testCollectSubmittedDataExpandedFormsErrors()
695695
$this->assertFalse(isset($child21Data['has_children_error']), 'The leaf data does not contains "has_children_error" property.');
696696
}
697697

698+
public function testReset()
699+
{
700+
$form = $this->createForm('my_form');
701+
702+
$this->dataExtractor->expects($this->any())
703+
->method('extractConfiguration')
704+
->will($this->returnValue(array()));
705+
$this->dataExtractor->expects($this->any())
706+
->method('extractDefaultData')
707+
->will($this->returnValue(array()));
708+
$this->dataExtractor->expects($this->any())
709+
->method('extractSubmittedData')
710+
->with($form)
711+
->will($this->returnValue(array('errors' => array('baz'))));
712+
713+
$this->dataCollector->buildPreliminaryFormTree($form);
714+
$this->dataCollector->collectSubmittedData($form);
715+
716+
$this->dataCollector->reset();
717+
718+
$this->assertSame(
719+
array(
720+
'forms' => array(),
721+
'forms_by_hash' => array(),
722+
'nb_errors' => 0,
723+
),
724+
$this->dataCollector->getData()
725+
);
726+
}
727+
698728
private function createForm($name)
699729
{
700730
$builder = new FormBuilder($name, null, $this->dispatcher, $this->factory);

0 commit comments

Comments
 (0)