Skip to content

Commit 9de22cf

Browse files
committed
replace mocks with real objects in tests
1 parent 9093b33 commit 9de22cf

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\Form\AbstractTypeExtension;
1617
use Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension;
1718
use Symfony\Component\Form\FormTypeGuesserChain;
@@ -21,9 +22,6 @@ class DependencyInjectionExtensionTest extends TestCase
2122
{
2223
public function testGetTypeExtensions()
2324
{
24-
$container = $this->createContainerMock();
25-
$container->expects($this->never())->method('get');
26-
2725
$typeExtension1 = new TestTypeExtension();
2826
$typeExtension2 = new TestTypeExtension();
2927
$typeExtension3 = new OtherTypeExtension();
@@ -34,7 +32,7 @@ public function testGetTypeExtensions()
3432
'other' => new \ArrayIterator([$typeExtension3, $typeExtension4]),
3533
];
3634

37-
$extension = new DependencyInjectionExtension($container, $extensions, []);
35+
$extension = new DependencyInjectionExtension(new ContainerBuilder(), $extensions, []);
3836

3937
$this->assertTrue($extension->hasTypeExtensions('test'));
4038
$this->assertTrue($extension->hasTypeExtensions('other'));
@@ -48,40 +46,28 @@ public function testGetTypeExtensions()
4846
*/
4947
public function testThrowExceptionForInvalidExtendedType()
5048
{
51-
$container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
52-
$container->expects($this->never())->method('get');
53-
5449
$extensions = [
5550
'unmatched' => new \ArrayIterator([new TestTypeExtension()]),
5651
];
5752

58-
$extension = new DependencyInjectionExtension($container, $extensions, []);
53+
$extension = new DependencyInjectionExtension(new ContainerBuilder(), $extensions, []);
5954

6055
$extension->getTypeExtensions('unmatched');
6156
}
6257

6358
public function testGetTypeGuesser()
6459
{
65-
$container = $this->createContainerMock();
66-
$extension = new DependencyInjectionExtension($container, [], [$this->getMockBuilder(FormTypeGuesserInterface::class)->getMock()]);
60+
$extension = new DependencyInjectionExtension(new ContainerBuilder(), [], [$this->getMockBuilder(FormTypeGuesserInterface::class)->getMock()]);
6761

6862
$this->assertInstanceOf(FormTypeGuesserChain::class, $extension->getTypeGuesser());
6963
}
7064

7165
public function testGetTypeGuesserReturnsNullWhenNoTypeGuessersHaveBeenConfigured()
7266
{
73-
$container = $this->createContainerMock();
74-
$extension = new DependencyInjectionExtension($container, [], []);
67+
$extension = new DependencyInjectionExtension(new ContainerBuilder(), [], []);
7568

7669
$this->assertNull($extension->getTypeGuesser());
7770
}
78-
79-
private function createContainerMock()
80-
{
81-
return $this->getMockBuilder('Psr\Container\ContainerInterface')
82-
->setMethods(['get', 'has'])
83-
->getMock();
84-
}
8571
}
8672

8773
class TestTypeExtension extends AbstractTypeExtension

0 commit comments

Comments
 (0)