Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/wbs24.ozonapinew/tests/unit/ |
Upload File : |
<?php namespace Wbs24\Ozonapinew; use Bitrix\Main\Loader; class OrdersSpecificTest extends BitrixTestCase { public function testChangeOrder() { // входные параметры $orderId = 1; $statusOnTradingPlatform = 'awaiting_deliver'; $phone = '+79990000012'; $shipmentDate = '2023-01-11T13:00:00Z'; // результат для проверки $expectedResult = true; // заглушки // Option $OptionStub = $this->createMock(Wrappers\Option::class); $OptionStub->method('get') ->will($this->returnCallback( function ($moduleId, $option) { $optionsResults = [ 'awaiting_deliver' => 'P', ]; return $optionsResults[$option] ?? ''; } )); // Bitrix\Sale\Order Loader::includeModule('sale'); $PropertyValueStub = $this->createMock(\Bitrix\Sale\PropertyValue::class); $PropertyValueStub->method('getValue') ->willReturn(''); $PropertyValueStub->expects($this->once()) // проверка ->method('setValue') ->willReturn(true); $PropertyValueCollectionStub = $this->createMock(\Bitrix\Sale\PropertyValueCollection::class); $PropertyValueCollectionStub->method('getPhone') ->willReturn($PropertyValueStub); $ResultStub = $this->createMock(\Bitrix\Sale\Result::class); $ResultStub->method('isSuccess') ->willReturn(true); $ExemplarOrderStub = $this->createMock(\Bitrix\Sale\Order::class); $ExemplarOrderStub->method('getField') ->willReturn("N"); $ExemplarOrderStub->expects($this->once()) // проверка ->method('setField') ->willReturn(true); $ExemplarOrderStub->method('getPropertyCollection') ->willReturn($PropertyValueCollectionStub); $ExemplarOrderStub->method('isPaid') ->willReturn(true); $ExemplarOrderStub->method('isShipped') ->willReturn(true); $ExemplarOrderStub->method('isCanceled') ->willReturn(true); $ExemplarOrderStub->expects($this->once()) // проверка ->method('save') ->willReturn($ResultStub); $OrderStub = $this->createMock(Wrappers\Order::class); $OrderStub->method('load') ->willReturn($ExemplarOrderStub); // вычисление результата $object = new Orders\Specific([ 'Option' => $OptionStub, 'Order' => $OrderStub, ]); $result = $object->changeOrder($orderId, [ 'statusOnTradingPlatform' => $statusOnTradingPlatform, 'phone' => $phone, 'shipmentDate' => $shipmentDate ]); // проверка $this->assertEquals($expectedResult, $result); } }