8000 [Form] do not use mocks in tests when not necessary by xabbuh · Pull Request #46030 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] do not use mocks in tests when not necessary #46030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions src/Symfony/Component/Form/Tests/AbstractFormTest.php

This file was deleted.

< 10000 /thead>
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\RequestHandlerInterface;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Util\ServerParams;

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

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

if ($compound) {
Expand Down
18 changes: 5 additions & 13 deletions src/Symfony/Component/Form/Tests/ButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,19 @@
namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\Exception\AlreadySubmittedException;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\ResolvedFormTypeFactory;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ButtonTest extends TestCase
{
private $dispatcher;

private $factory;

protected function setUp(): void
{
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->factory = $this->createMock(FormFactoryInterface::class);
}

public function testSetParentOnSubmittedButton()
{
$this->expectException(AlreadySubmittedException::class);
Expand Down Expand Up @@ -83,6 +75,6 @@ private function getButtonBuilder($name)

private function getFormBuilder()
{
return new FormBuilder('form', null, $this->dispatcher, $this->factory);
return new FormBuilder('form', null, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())));
}
}
Loading
0