|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) MIKO LLC - All Rights Reserved |
|
4
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited |
|
5
|
|
|
* Proprietary and confidential |
|
6
|
|
|
* Written by Nikolay Beketov, 6 2020 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace MikoPBX\Tests\Core\System; |
|
11
|
|
|
|
|
12
|
|
|
use MikoPBX\Core\System\Util; |
|
13
|
|
|
use MikoPBX\Core\Workers\Cron\WorkerSafeScriptsCore; |
|
14
|
|
|
use MikoPBX\Tests\Unit\AbstractUnitTest; |
|
15
|
|
|
use Modules\ModuleBitrix24Integration\Lib\WorkerBitrix24IntegrationAMI; |
|
16
|
|
|
|
|
17
|
|
|
class UtilTest extends AbstractUnitTest |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
public function testMwExec() |
|
21
|
|
|
{ |
|
22
|
|
|
$resultCode = 0; |
|
23
|
|
|
$output = []; |
|
24
|
|
|
$path_asterisk = Util::which('asterisk'); |
|
25
|
|
|
Util::mwExec("{$path_asterisk} -rx 'dialplan reload'", $output,$resultCode); |
|
26
|
|
|
$this->assertIsArray($output); |
|
27
|
|
|
$this->assertIsInt($resultCode); |
|
28
|
|
|
$this->assertStringContainsStringIgnoringCase('Dialplan reloaded.', implode(' ', $output)); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testkillByName(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$process = WorkerBitrix24IntegrationAMI::class; |
|
34
|
|
|
Util::killByName($process); |
|
35
|
|
|
$this->assertTrue(true); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testRestartPHPWorker(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$process = WorkerBitrix24IntegrationAMI::class; |
|
41
|
|
|
Util::restartPHPWorker($process); |
|
42
|
|
|
$this->assertTrue(true); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testMwMkdir(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$parameters = '/tmp/1 /tmp/2 '; |
|
48
|
|
|
Util::mwMkdir($parameters); |
|
49
|
|
|
|
|
50
|
|
|
$parameters = '/tmp/1'; |
|
51
|
|
|
Util::mwMkdir($parameters); |
|
52
|
|
|
$this->assertTrue(true); |
|
53
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testGetFilePathByClassName(): void |
|
57
|
|
|
{ |
|
58
|
|
|
$process = WorkerSafeScriptsCore::class; |
|
59
|
|
|
$path = Util::getFilePathByClassName($process); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertFileExists($path); |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|