Skip to content

Commit

Permalink
Change from createMock to createStub
Browse files Browse the repository at this point in the history
Changes mocks from stubs when these mocks do not have any
expectation.
  • Loading branch information
franmomu committed Dec 11, 2020
1 parent 28fe03b commit 47afea9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions tests/Admin/AdminHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function testDeprecatedConstructingWithoutPropertyAccessor(): void

public function testGetChildFormBuilder(): void
{
$formFactory = $this->createMock(FormFactoryInterface::class);
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$formFactory = $this->createStub(FormFactoryInterface::class);
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);

$formBuilder = new FormBuilder('test', \stdClass::class, $eventDispatcher, $formFactory);

Expand Down Expand Up @@ -235,7 +235,7 @@ public function testAppendFormFieldElement(): void
{
$helper = new AdminHelper($this->propertyAccessor);

$admin = $this->createMock(AdminInterface::class);
$admin = $this->createStub(AdminInterface::class);
$admin
->method('getClass')
->willReturn(Foo::class);
Expand All @@ -252,7 +252,7 @@ public function testAppendFormFieldElement(): void
'isOwningSide' => false,
];

$fieldDescription = $this->createMock(FieldDescriptionInterface::class);
$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription->method('getAssociationAdmin')->willReturn($associationAdmin);
$fieldDescription->method('getAssociationMapping')->willReturn($associationMapping);
$fieldDescription->method('getParentAssociationMappings')->willReturn([]);
Expand All @@ -267,7 +267,7 @@ public function testAppendFormFieldElement(): void
'bar' => $fieldDescription,
]);

$request = $this->createMock(Request::class);
$request = $this->createStub(Request::class);
$request
->method('get')
->willReturn([
Expand All @@ -285,7 +285,7 @@ public function testAppendFormFieldElement(): void

$admin
->method('getRequest')
->will($this->onConsecutiveCalls($request, $request, $request, null, $request, $request, $request, $request, null, $request));
->willReturnOnConsecutiveCalls($request, $request, $request, null, $request, $request, $request, $request, null, $request);

$foo = $this->createMock(Foo::class);
$admin
Expand All @@ -303,9 +303,9 @@ public function testAppendFormFieldElement(): void

$foo->expects($this->atLeastOnce())->method('addBar')->with($bar);

$dataMapper = $this->createMock(DataMapperInterface::class);
$formFactory = $this->createMock(FormFactoryInterface::class);
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$dataMapper = $this->createStub(DataMapperInterface::class);
$formFactory = $this->createStub(FormFactoryInterface::class);
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);
$formBuilder = new FormBuilder('test', \get_class($foo), $eventDispatcher, $formFactory);
$childFormBuilder = new FormBuilder('bar', \stdClass::class, $eventDispatcher, $formFactory);
$childFormBuilder->setCompound(true);
Expand Down Expand Up @@ -343,21 +343,21 @@ public function testAppendFormFieldElementNested(): void
{
$admin = $this->createMock(AdminInterface::class);
$object = $this->getMockBuilder(\stdClass::class)
->setMethods(['getSubObject'])
->addMethods(['getSubObject'])
->getMock();

$subObject = $this->getMockBuilder(\stdClass::class)
->setMethods(['getAnd'])
->addMethods(['getAnd'])
->getMock();
$sub2Object = $this->getMockBuilder(\stdClass::class)
->setMethods(['getMore'])
->addMethods(['getMore'])
->getMock();
$sub3Object = $this->getMockBuilder(\stdClass::class)
->setMethods(['getFinalData'])
->addMethods(['getFinalData'])
->getMock();
$dataMapper = $this->createMock(DataMapperInterface::class);
$formFactory = $this->createMock(FormFactoryInterface::class);
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$dataMapper = $this->createStub(DataMapperInterface::class);
$formFactory = $this->createStub(FormFactoryInterface::class);
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);
$formBuilder = new FormBuilder('test', \get_class($object), $eventDispatcher, $formFactory);
$childFormBuilder = new FormBuilder('subObject', \get_class($subObject), $eventDispatcher, $formFactory);

Expand Down
4 changes: 2 additions & 2 deletions tests/Util/FormBuilderIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class FormBuilderIteratorTest extends TestCase

protected function setUp(): void
{
$this->dispatcher = $this->getMockForAbstractClass(EventDispatcherInterface::class);
$this->factory = $this->getMockForAbstractClass(FormFactoryInterface::class);
$this->dispatcher = $this->createStub(EventDispatcherInterface::class);
$this->factory = $this->createStub(FormFactoryInterface::class);
$this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory);
$this->factory->method('createNamedBuilder')->willReturn($this->builder);
}
Expand Down

0 comments on commit 47afea9

Please sign in to comment.