| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function testPaymentSetPaid() |
||
| 27 | { |
||
| 28 | $request = $this->prophet->prophesize('Symfony\Component\HttpFoundatio\Request'); |
||
| 29 | $request->willExtend('Symfony\Component\HttpFoundation\Request'); |
||
| 30 | |||
| 31 | $wayforpayService = $this->prophet->prophesize('Application\Bundle\DefaultBundle\Service\WayForPayService'); |
||
| 32 | $paymentService = $this->prophet->prophesize('Application\Bundle\DefaultBundle\Service\PaymentService'); |
||
| 33 | |||
| 34 | $container = $this->prophet->prophesize('Symfony\Component\DependencyInjection\Container'); |
||
| 35 | $doctrine = $this->prophet->prophesize('Doctrine\Bundle\DoctrineBundle\Registry'); |
||
| 36 | $em = $this->prophet->prophesize('Doctrine\ORM\EntityManager'); |
||
| 37 | $paymentRepository = $this->prophet->prophesize('Stfalcon\Bundle\EventBundle\Repository\PaymentRepository'); |
||
| 38 | $payment = $this->prophet->prophesize('Stfalcon\Bundle\EventBundle\Entity\Payment'); |
||
| 39 | $logger = $this->prophet->prophesize('Symfony\Bridge\Monolog\Logger'); |
||
| 40 | $referralService = $this->prophet->prophesize('Application\Bundle\DefaultBundle\Service\ReferralService'); |
||
| 41 | $session = $this->prophet->prophesize('Symfony\Component\HttpFoundation\Session\Session'); |
||
| 42 | |||
| 43 | $request->getContent()->shouldBeCalled() |
||
| 44 | ->willReturn('{"orderNo":"1"}'); |
||
| 45 | |||
| 46 | $doctrine->getRepository('StfalconEventBundle:Payment') |
||
| 47 | ->shouldBeCalled() |
||
| 48 | ->willReturn($paymentRepository); |
||
| 49 | |||
| 50 | $doctrine->getManager()->willReturn($em); |
||
| 51 | |||
| 52 | $payment->isPending()->shouldBeCalled()->willReturn(true); |
||
| 53 | $payment->setPaidWithGate(Payment::WAYFORPAY_GATE)->shouldBeCalled(); |
||
| 54 | |||
| 55 | $session->set('way_for_pay_payment', 1)->shouldBeCalled()->willReturn(null); |
||
| 56 | |||
| 57 | $referralService->chargingReferral($payment)->shouldBeCalled()->willReturn(null); |
||
| 58 | $referralService->utilizeBalance($payment)->shouldBeCalled()->willReturn(null); |
||
| 59 | |||
| 60 | $container->has('doctrine')->willReturn(true); |
||
| 61 | $container->get('doctrine')->willReturn($doctrine); |
||
| 62 | |||
| 63 | $paymentRepository->findOneBy(Argument::any())->willReturn($payment); |
||
| 64 | |||
| 65 | $container->get('app.way_for_pay.service')->willReturn($wayforpayService); |
||
| 66 | $container->get('stfalcon_event.referral.service')->willReturn($referralService); |
||
| 67 | $container->get('stfalcon_event.payment.service')->willReturn($paymentService); |
||
| 68 | $container->get('logger')->willReturn($logger); |
||
| 69 | $container->get('session')->willReturn($session); |
||
| 70 | |||
| 71 | $wayforpayService->checkPayment(Argument::any(), Argument::any()) |
||
| 72 | ->willReturn(true) |
||
| 73 | ->shouldBeCalled(); |
||
| 74 | $wayforpayService->saveResponseLog($payment, Argument::any(), 'set paid')->willReturn(null) |
||
| 75 | ->shouldBeCalled(); |
||
| 76 | $wayforpayService->getResponseOnServiceUrl(Argument::any())->willReturn([]) |
||
| 77 | ->shouldBeCalled(); |
||
| 78 | $em->flush()->shouldBeCalled(); |
||
| 79 | |||
| 80 | $wayforpayController = new WayForPayController(); |
||
| 81 | $wayforpayController->setContainer($container->reveal()); |
||
| 82 | $result = $wayforpayController->serviceInteractionAction($request->reveal()); |
||
| 83 | |||
| 84 | $this->assertEquals(200, $result->getStatusCode()); |
||
| 85 | } |
||
| 124 |