Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Merge b4da0a3 into 11b6599
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh authored May 8, 2019
2 parents 11b6599 + b4da0a3 commit a8f5da6
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion tests/Backend/BackendHealthCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testCheck(): void
$result = new Success('Test check', 'OK');

$backend = $this->createMock(BackendInterface::class);
$backend->expects($this->once())->method('getStatus')->will($this->returnValue($result));
$backend->expects($this->once())->method('getStatus')->willReturn($result);

$health = new BackendHealthCheck($backend);

Expand Down
2 changes: 1 addition & 1 deletion tests/Backend/MessageManagerBackendDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testCreate(): void

$testBackend->expects($this->once())
->method('create')
->will($this->returnValue($message))
->willReturn($message)
;

$mMgr = $this->createMock(MessageManagerInterface::class);
Expand Down
10 changes: 5 additions & 5 deletions tests/Backend/MessageManagerBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function testCreateAndPublish(): void
{
$message = new Message();
$modelManager = $this->createMock(MessageManagerInterface::class);
$modelManager->expects($this->once())->method('save')->will($this->returnValue($message));
$modelManager->expects($this->once())->method('create')->will($this->returnValue($message));
$modelManager->expects($this->once())->method('save')->willReturn($message);
$modelManager->expects($this->once())->method('create')->willReturn($message);

$backend = new MessageManagerBackend($modelManager, []);
$message = $backend->createAndPublish('foo', ['message' => 'salut']);
Expand All @@ -47,7 +47,7 @@ public function testHandleSuccess(): void
{
$message = new Message();
$modelManager = $this->createMock(MessageManagerInterface::class);
$modelManager->expects($this->exactly(2))->method('save')->will($this->returnValue($message));
$modelManager->expects($this->exactly(2))->method('save')->willReturn($message);

$dispatcher = $this->createMock(EventDispatcherInterface::class);
$dispatcher->expects($this->once())->method('dispatch');
Expand All @@ -65,7 +65,7 @@ public function testHandleError(): void
{
$message = new Message();
$modelManager = $this->createMock(MessageManagerInterface::class);
$modelManager->expects($this->exactly(2))->method('save')->will($this->returnValue($message));
$modelManager->expects($this->exactly(2))->method('save')->willReturn($message);

$dispatcher = $this->createMock(EventDispatcherInterface::class);
$dispatcher->expects($this->once())->method('dispatch')->will($this->throwException(new \RuntimeException()));
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testStatus($counts, $expectedStatus, $message): void
}

$modelManager = $this->createMock(MessageManagerInterface::class);
$modelManager->expects($this->exactly(1))->method('countStates')->will($this->returnValue($counts));
$modelManager->expects($this->exactly(1))->method('countStates')->willReturn($counts);

$backend = new MessageManagerBackend($modelManager, [
MessageInterface::STATE_IN_PROGRESS => 10,
Expand Down
2 changes: 1 addition & 1 deletion tests/Consumer/SwiftMailerConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testSendEmail(): void
->method('attach')
->willReturnSelf();

$this->mailer->expects($this->once())->method('createMessage')->will($this->returnValue($mail));
$this->mailer->expects($this->once())->method('createMessage')->willReturn($mail);

$method = new \ReflectionMethod($this->consumer, 'sendEmail');
$method->setAccessible(true);
Expand Down
20 changes: 10 additions & 10 deletions tests/Controller/Api/MessageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class MessageControllerTest extends TestCase
public function testGetMessagesAction(): void
{
$messageManager = $this->createMock(MessageManagerInterface::class);
$messageManager->expects($this->once())->method('getPager')->will($this->returnValue([]));
$messageManager->expects($this->once())->method('getPager')->willReturn([]);

$paramFetcher = $this->createMock(ParamFetcher::class);
$paramFetcher->expects($this->exactly(3))->method('get');
$paramFetcher->expects($this->once())->method('all')->will($this->returnValue([]));
$paramFetcher->expects($this->once())->method('all')->willReturn([]);

$this->assertSame([], $this->createMessageController(null, $messageManager)->getMessagesAction($paramFetcher));
}
Expand All @@ -46,15 +46,15 @@ public function testPostMessageAction(): void
$message = $this->createMock(MessageInterface::class);

$messageManager = $this->createMock(MessageManagerInterface::class);
$messageManager->expects($this->once())->method('save')->will($this->returnValue($message));
$messageManager->expects($this->once())->method('save')->willReturn($message);

$form = $this->createMock(Form::class);
$form->expects($this->once())->method('handleRequest');
$form->expects($this->once())->method('isValid')->will($this->returnValue(true));
$form->expects($this->once())->method('getData')->will($this->returnValue($message));
$form->expects($this->once())->method('isValid')->willReturn(true);
$form->expects($this->once())->method('getData')->willReturn($message);

$formFactory = $this->createMock(FormFactoryInterface::class);
$formFactory->expects($this->once())->method('createNamed')->will($this->returnValue($form));
$formFactory->expects($this->once())->method('createNamed')->willReturn($form);

$message = $this->createMessageController(null, $messageManager, $formFactory)->postMessageAction(new Request());

Expand All @@ -66,14 +66,14 @@ public function testPostMessageInvalidAction(): void
$message = $this->createMock(MessageInterface::class);

$messageManager = $this->createMock(MessageManagerInterface::class);
$messageManager->expects($this->never())->method('save')->will($this->returnValue($message));
$messageManager->expects($this->never())->method('save')->willReturn($message);

$form = $this->createMock(Form::class);
$form->expects($this->once())->method('handleRequest');
$form->expects($this->once())->method('isValid')->will($this->returnValue(false));
$form->expects($this->once())->method('isValid')->willReturn(false);

$formFactory = $this->createMock(FormFactoryInterface::class);
$formFactory->expects($this->once())->method('createNamed')->will($this->returnValue($form));
$formFactory->expects($this->once())->method('createNamed')->willReturn($form);

$form = $this->createMessageController(null, $messageManager, $formFactory)->postMessageAction(new Request());

Expand All @@ -93,7 +93,7 @@ public function createMessageController($message = null, $messageManager = null,
$messageManager = $this->createMock(SiteManagerInterface::class);
}
if (null !== $message) {
$messageManager->expects($this->once())->method('findOneBy')->will($this->returnValue($message));
$messageManager->expects($this->once())->method('findOneBy')->willReturn($message);
}
if (null === $formFactory) {
$formFactory = $this->createMock(FormFactoryInterface::class);
Expand Down
18 changes: 9 additions & 9 deletions tests/Entity/MessageManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,32 +192,32 @@ protected function getMessageManager($qbCallback)
true,
['execute']
);
$query->expects($this->any())->method('execute')->will($this->returnValue(true));
$query->expects($this->any())->method('execute')->willReturn(true);

$qb = $this->getMockBuilder(QueryBuilder::class)
->setConstructorArgs([$this->createMock(EntityManager::class)])
->getMock();

$qb->expects($this->any())->method('select')->will($this->returnValue($qb));
$qb->expects($this->any())->method('getQuery')->will($this->returnValue($query));
$qb->expects($this->any())->method('select')->willReturn($qb);
$qb->expects($this->any())->method('getQuery')->willReturn($query);

$qbCallback($qb);

$repository = $this->createMock(EntityRepository::class);
$repository->expects($this->any())->method('createQueryBuilder')->will($this->returnValue($qb));
$repository->expects($this->any())->method('createQueryBuilder')->willReturn($qb);

$metadata = $this->createMock(ClassMetadata::class);
$metadata->expects($this->any())->method('getFieldNames')->will($this->returnValue([
$metadata->expects($this->any())->method('getFieldNames')->willReturn([
'state',
'type',
]));
]);

$em = $this->createMock(EntityManager::class);
$em->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
$em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($metadata));
$em->expects($this->any())->method('getRepository')->willReturn($repository);
$em->expects($this->any())->method('getClassMetadata')->willReturn($metadata);

$registry = $this->createMock(ManagerRegistry::class);
$registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em));
$registry->expects($this->any())->method('getManagerForClass')->willReturn($em);

return new MessageManager(BaseMessage::class, $registry);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Event/DoctrineOptimizeListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public function testWithClosedManager(): void
$this->expectException(\RuntimeException::class);

$manager = $this->createMock(EntityManager::class);
$manager->expects($this->once())->method('isOpen')->will($this->returnValue(false));
$manager->expects($this->once())->method('isOpen')->willReturn(false);

$registry = $this->createMock(RegistryInterface::class);
$registry->expects($this->once())->method('getManagers')->will($this->returnValue([
$registry->expects($this->once())->method('getManagers')->willReturn([
'default' => $manager,
]));
]);

$optimizer = new DoctrineOptimizeListener($registry);
$optimizer->iterate(new IterateEvent(
Expand All @@ -49,13 +49,13 @@ public function testOptimize(): void
$unitofwork->expects($this->once())->method('clear');

$manager = $this->createMock(EntityManager::class);
$manager->expects($this->once())->method('isOpen')->will($this->returnValue(true));
$manager->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($unitofwork));
$manager->expects($this->once())->method('isOpen')->willReturn(true);
$manager->expects($this->once())->method('getUnitOfWork')->willReturn($unitofwork);

$registry = $this->createMock(RegistryInterface::class);
$registry->expects($this->once())->method('getManagers')->will($this->returnValue([
$registry->expects($this->once())->method('getManagers')->willReturn([
'default' => $manager,
]));
]);

$optimizer = new DoctrineOptimizeListener($registry);
$optimizer->iterate(new IterateEvent(
Expand Down
8 changes: 4 additions & 4 deletions tests/Iterator/IteratorProxyMessageIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ public function expectIterator($mock, array $content, $withKey = false, $counter
$mock
->expects($this->at(++$counter))
->method('valid')
->will($this->returnValue(true))
->willReturn(true)
;

$mock
->expects($this->at(++$counter))
->method('current')
->will($this->returnValue($value))
->willReturn($value)
;

if ($withKey) {
$mock
->expects($this->at(++$counter))
->method('key')
->will($this->returnValue($key))
->willReturn($key)
;
}

Expand All @@ -78,7 +78,7 @@ public function expectIterator($mock, array $content, $withKey = false, $counter
$mock
->expects($this->at(++$counter))
->method('valid')
->will($this->returnValue(false))
->willReturn(false)
;

return ++$counter;
Expand Down

0 comments on commit a8f5da6

Please sign in to comment.