getOrderStatusByState($order, 'new'); self::assertEquals($expectedReturn, $actualReturn); } /** * @return array */ public function statesDataProvider() { return [ [ $this->getOrder('pending', ['pending' => 'pending']), 'pending' ], [ $this->getOrder('processing', ['pending' => 'pending']), 'processing' ], ]; } /** * @param string $newOrderStatus * @param array $stateStatuses * @return OrderInterface|MockObject */ private function getOrder($newOrderStatus, $stateStatuses) { $order = $this->getMockBuilder(OrderInterface::class) ->setMethods(['getConfig']) ->getMockForAbstractClass(); $order->method('getPayment') ->willReturn($this->getPayment($newOrderStatus)); $order->method('getConfig') ->willReturn($this->getConfig($stateStatuses)); return $order; } /** * @param string $newOrderStatus * @return MockObject */ private function getPayment($newOrderStatus) { $payment = $this->getMockBuilder(OrderPaymentInterface::class) ->setMethods(['getMethodInstance']) ->getMockForAbstractClass(); $payment->method('getMethodInstance') ->willReturn($this->getMethodInstance($newOrderStatus)); return $payment; } /** * @param string $newOrderStatus * @return MethodInterface|MockObject */ private function getMethodInstance($newOrderStatus) { $methodInstance = $this->getMockBuilder(MethodInterface::class) ->getMockForAbstractClass(); $methodInstance->method('getConfigData') ->with('order_status') ->willReturn($newOrderStatus); return $methodInstance; } /** * @param array $stateStatuses * @return Config|MockObject */ private function getConfig($stateStatuses) { $config = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); $config->method('getStateStatuses') ->willReturn($stateStatuses); $config->method('getStateDefaultStatus') ->willReturn('processing'); return $config; } }