8000 minor #46030 [Form] do not use mocks in tests when not necessary (xab… · symfony/symfony@aa54aff · GitHub
[go: up one dir, main page]

Skip to content

Commit aa54aff

Browse files
committed
minor #46030 [Form] do not use mocks in tests when not necessary (xabbuh)
This PR was merged into the 4.4 branch. Discussion ---------- [Form] do not use mocks in tests when not necessary | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Commits ------- a53b450 do not use mocks in tests when not necessary
2 parents 0d3c0a7 + a53b450 commit aa54aff

39 files changed

+1284
-2213
lines changed

src/Symfony/Component/Form/Tests/AbstractFormTest.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
use Symfony\Component\Form\FormBuilder;
1919
use Symfony\Component\Form\FormError;
2020
use Symfony\Component\Form\FormFactory;
21-
use Symfony\Component\Form\FormFactoryInterface;
21+
use Symfony\Component\Form\FormRegistry;
2222
use Symfony\Component\Form\Forms;
2323
use Symfony\Component\Form\RequestHandlerInterface;
24+
use Symfony\Component\Form\ResolvedFormTypeFactory;
2425
use Symfony\Component\Form\Util\ServerParams;
2526

2627
/**
@@ -417,7 +418,7 @@ protected function createForm($name, $method = null, $compound = false)
417418

418419
protected function createBuilder($name, $compound = false, array $options = [])
419420
{
420-
$builder = new FormBuilder($name, null, new EventDispatcher(), $this->createMock(FormFactoryInterface::class), $options);
421+
$builder = new FormBuilder($name, null, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())), $options);
421422
$builder->setCompound($compound);
422423

423424
if ($compound) {

src/Symfony/Component/Form/Tests/ButtonTest.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,19 @@
1212
namespace Symfony\Component\Form\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15+
use Symfony\Component\EventDispatcher\EventDispatcher;
1616
use Symfony\Component\Form\ButtonBuilder;
1717
use Symfony\Component\Form\Exception\AlreadySubmittedException;
1818
use Symfony\Component\Form\FormBuilder;
19-
use Symfony\Component\Form\FormFactoryInterface;
19+
use Symfony\Component\Form\FormFactory;
20+
use Symfony\Component\Form\FormRegistry;
21+
use Symfony\Component\Form\ResolvedFormTypeFactory;
2022

2123
/**
2224
* @author Bernhard Schussek <bschussek@gmail.com>
2325
*/
2426
class ButtonTest extends TestCase
2527
{
26-
private $dispatcher;
27-
28-
private $factory;
29-
30-
protected function setUp(): void
31-
{
32-
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
33-
$this->factory = $this->createMock(FormFactoryInterface::class);
34-
}
35-
3628
public function testSetParentOnSubmittedButton()
3729
{
3830
$this->expectException(AlreadySubmittedException::class);
@@ -83,6 +75,6 @@ private function getButtonBuilder($name)
8375

8476
private function getFormBuilder()
8577
{
86-
return new FormBuilder('form', null, $this->dispatcher, $this->factory);
78+
return new FormBuilder('form', null, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())));
8779
}
8880
}

0 commit comments

Comments
 (0)
0