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; class DbTest extends BitrixTestCase { public function testSet() { // входные параметры $table = 'wbs24_ozonapinew_orders_stack'; $order = <<<ORDER s:1331:"{"result":{"posting_number":"51140602-0066-1","order_id":683792568,"order_number":"51140602-0066","status":"awaiting_deliver","delivery_method":{"id":22876206478000,"name":"Ozon","warehouse_id":22876206478000,"warehouse":"FBS","tpl_provider_id":24,"tpl_provider":"Ozon"},"tracking_number":"","tpl_integration_type":"ozon","in_process_at":"2022-05-15T19:57:58Z","shipment_date":"2022-05-17T10:00:00Z","delivering_date":null,"provider_status":"","delivery_price":"","cancellation":{"cancel_reason_id":0,"cancel_reason":"","cancellation_type":"","cancelled_after_ship":false,"affect_cancellation_rating":false,"cancellation_initiator":""},"customer":null,"addressee":null,"products":[{"price":"532.000000","offer_id":"001223-ab","name":"Л'Этуаль","sku":545417214,"quantity":1,"mandatory_mark":["010290002480445621kr';RY:bGBN4("],"dimensions":{"height":"50.00","length":"350.00","weight":"200","width":"350.00"},"currency_code":"RUB"}],"barcodes":null,"analytics_data":null,"financial_data":null,"additional_data":[],"is_express":false,"requirements":{"products_requiring_gtd":[],"products_requiring_country":[],"products_requiring_mandatory_mark":[545417214]},"product_exemplars":{"products":[{"sku":545417214,"exemplars":[{"mandatory_mark":"010290002480445621kr';RY:bGBN4(","gtd":"","is_gtd_absent":false}]}]},"courier":null}}"; ORDER; $data = [ 'external_id' => '51140602-0066-1', 'order' => $order, ]; $escapeOrder = addslashes($order); // результат для проверки $expectedResult = <<<RESULT INSERT INTO `wbs24_ozonapinew_orders_stack` (`external_id`, `order`) VALUES ('51140602-0066-1', '{$escapeOrder}') ON DUPLICATE KEY UPDATE `external_id` = '51140602-0066-1', `order` = '{$escapeOrder}' RESULT; // заглушки $CDBResultStub = $this->createMock(\CDBResult::class); $CDBResultStub->method('Fetch') ->willReturn(false); $CDatabaseStub = $this->createMock(\CDatabase::class); $CDatabaseStub->method('Query') ->willReturn($CDBResultStub); // проверка $CDatabaseStub->expects($this->once()) ->method('Query') ->with($this->equalTo($expectedResult)); // вычисление результата $db = new Db([ 'DB' => $CDatabaseStub, ]); $db->set($table, $data); } public function testGetWhereAsSql() { // входные параметры $where = [ 'A' => 1, '>B' => 2, '<C' => 3, 'E' => "text's\\other", ]; // результат для проверки $expectedResult = "`A` = '1' AND `B` > 2 AND `C` < 3 AND `E` = 'text\\'s\\\\other'"; // заглушки $DBStub = new \stdClass(); // вычисление результата $object = new Db([ 'DB' => $DBStub, ]); $result = $object->getWhereAsSql($where); // проверка $this->assertEquals($expectedResult, $result); } }