|
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 testNoValidPid() |
|
25
|
|
|
{ |
|
26
|
|
|
file_put_contents(self::$existFileName, "12as"); |
|
27
|
|
|
|
|
28
|
|
|
$this->expectException("DanchukAS\DenyMultiplyRun\Exception\ConvertPidFail"); |
|
29
|
|
|
DenyMultiplyRun::setPidFile(self::$existFileName); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
public function testBiggerPid() |
|
34
|
|
|
{ |
|
35
|
|
|
file_put_contents(self::$existFileName, PHP_INT_MAX); |
|
36
|
|
|
|
|
37
|
|
|
$this->expectException("DanchukAS\DenyMultiplyRun\Exception\PidBiggerMax"); |
|
38
|
|
|
DenyMultiplyRun::setPidFile(self::$existFileName); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testNoAccessFile() |
|
42
|
|
|
{ |
|
43
|
|
|
// existed file without write access for current user. |
|
44
|
|
|
// for Ubuntu is /etc/hosts. |
|
45
|
|
|
$file_name = "/etc/hosts"; |
|
46
|
|
|
|
|
47
|
|
|
if (!file_exists($file_name)) { |
|
48
|
|
|
self::markTestSkipped("test only for *nix."); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if (is_writable($file_name)) { |
|
52
|
|
|
self::markTestSkipped("test runned under super/admin user. Change user."); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$this->expectException("DanchukAS\DenyMultiplyRun\Exception\OpenFileFail"); |
|
56
|
|
|
DenyMultiplyRun::setPidFile($file_name); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|