Completed
Pull Request — master (#20)
by Anatoliy
18:45 queued 08:46
created

ExistWrongPidFileTest::testNoAccessFile()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 0
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * Created by PhpStorm.
5
 * User: danchukas
6
 * Date: 2017-07-15 00:56
7
 */
8
9
namespace DanchukAS\DenyMultiplyRunTest;
10
11
use DanchukAS\DenyMultiplyRun\DenyMultiplyRun;
12
use DanchukAS\DenyMultiplyRun\PidFileTestCase;
13
14
/** @noinspection PhpClassNamingConventionInspection */
15
16
/**
17
 * Class ExistWrongPidFileTest
18
 * Тести на невірний під файл
19
 * @package DanchukAS\DenyMultiplyRunTest
20
 */
21
class ExistWrongPidFileTest extends PidFileTestCase
22
{
23
24
    public function testBiggerPid()
25
    {
26
        file_put_contents(self::$existFileName, PHP_INT_MAX);
27
28
        $this->expectException("DanchukAS\DenyMultiplyRun\Exception\PidBiggerMax");
29
        DenyMultiplyRun::setPidFile(self::$existFileName);
30
    }
31
32
    public function testNoAccessFile()
33
    {
34
        // existed file without write access for current user.
35
        // for Ubuntu is /etc/hosts.
36
        $file_name = "/etc/hosts";
37
38
        if (!file_exists($file_name)) {
39
            self::markTestSkipped("test only for *nix.");
40
        }
41
42
        if (is_writable($file_name)) {
43
            self::markTestSkipped("test runned under super/admin user. Change user.");
44
        }
45
46
        $this->expectException("DanchukAS\DenyMultiplyRun\Exception\OpenFileFail");
47
        DenyMultiplyRun::setPidFile($file_name);
48
    }
49
}
50