Skip to content

Commit 0c75820

Browse files
committed
do not use mocks in tests when not necessary
1 parent a90648c commit 0c75820

39 files changed

+1284
-2213
lines changed

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

-77
This file was deleted.

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

+3-2
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

+5-13
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)