-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFunctionCommandTest.php
More file actions
50 lines (39 loc) · 1.27 KB
/
FunctionCommandTest.php
File metadata and controls
50 lines (39 loc) · 1.27 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
<?php
namespace GT\Cron\Test;
use GT\Cron\FunctionCommand;
use GT\Cron\FunctionExecutionException;
use GT\Cron\Test\Helper\ExampleClass;
use PHPUnit\Framework\TestCase;
class FunctionCommandTest extends TestCase {
protected function setUp():void {
ExampleClass::$calls = 0;
ExampleClass::$message = "";
ExampleClass::$counter = 0;
}
public function testIsCallableReturnsTrueForStaticMethod():void {
$command = new FunctionCommand();
self::assertTrue($command->isCallable(
"GT\\Cron\\Test\\Helper\\ExampleClass::doSomething"
));
}
public function testIsCallableReturnsFalseForShellCommand():void {
$command = new FunctionCommand();
self::assertFalse($command->isCallable("php -v"));
}
public function testExecuteCallsFunctionWithArguments():void {
$command = new FunctionCommand();
$command->execute(
'GT\\Cron\\Test\\Helper\\ExampleClass::doSomething("hello", 5)'
);
self::assertSame(1, ExampleClass::$calls);
self::assertSame("hello", ExampleClass::$message);
self::assertSame(5, ExampleClass::$counter);
}
public function testExecuteThrowsForMissingMethod():void {
$command = new FunctionCommand();
self::expectException(FunctionExecutionException::class);
$command->execute(
"GT\\Cron\\Test\\Helper\\ExampleClass::doesNotExist"
);
}
}