-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLuaScriptTest.php
More file actions
71 lines (59 loc) · 1.76 KB
/
Copy pathLuaScriptTest.php
File metadata and controls
71 lines (59 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Qless\Tests;
use Qless\Exceptions\RuntimeException;
use Qless\LuaScript;
use Qless\Tests\Support\RedisAwareTrait;
/**
* Qless\Tests\ListenerTest
*
* @package Qless\Tests
*/
class LuaScriptTest extends QlessTestCase
{
use RedisAwareTrait;
private $corePath;
/**
* {@inheritdoc}
*
* @return void
*/
public function setUp(): void
{
$this->corePath = dirname(__DIR__) . '/src/qless-core/qless.lua';
if (file_exists($this->corePath . '.back')) {
@unlink($this->corePath . '.back');
}
if (file_exists($this->corePath)) {
rename($this->corePath, $this->corePath . '.back');
}
parent::setUp();
}
/**
* {@inheritdoc}
*
* @return void
*/
public function tearDown(): void
{
if (file_exists($this->corePath . '.back') && !file_exists($this->corePath)) {
rename($this->corePath . '.back', $this->corePath);
} elseif (file_exists($this->corePath . '.back')) {
@unlink($this->corePath . '.back');
}
parent::tearDown();
}
/**
* @test
*/
public function shouldThrowExpectedExceptionWhenLuaCoreDoesNotExists(): void {
// If runs on phpunit/phpunit:^8.5 call new method, else - fallback to old method
if (method_exists($this, 'expectExceptionMessageMatches')) {
$this->expectExceptionMessageMatches('~Unable to locate qless-core file at path: .*~');
} else {
$this->expectExceptionMessageRegExp('~Unable to locate qless-core file at path: .*~');
}
$this->expectException(RuntimeException::class);
$luaScript = new LuaScript($this->redis());
$luaScript->run('some-command', []);
}
}