Passed
Push — develop ( 48ed7a...f087ba )
by Nikolay
05:31
created

UtilTest::testGetFilePathByClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
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);
0 ignored issues
show
Bug introduced by
It seems like $path can also be of type null; however, parameter $filename of PHPUnit\Framework\Assert::assertFileExists() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

61
        $this->assertFileExists(/** @scrutinizer ignore-type */ $path);
Loading history...
62
    }
63
64
}
65