Repository navigation
Expand file tree
/
Copy pathCrontabAnnotationTest.php
More file actions
70 lines (61 loc) · 1.98 KB
/
Copy pathCrontabAnnotationTest.php
File metadata and controls
70 lines (61 loc) · 1.98 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
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace HyperfTest\Crontab;
use Hyperf\Crontab\Annotation\Crontab;
use HyperfTest\Crontab\Stub\FooCron;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;
/**
* @internal
* @coversNothing
*/
#[CoversNothing]
class CrontabAnnotationTest extends TestCase
{
public function testCallableNotExist()
{
$this->expectException(InvalidArgumentException::class);
$annotation = new Crontab();
$annotation->collectClass(FooCron::class);
}
public function testCallableNormal()
{
$annotation = new Crontab();
$annotation->callback = 'execute';
$annotation->collectClass(FooCron::class);
$this->assertEquals([FooCron::class, 'execute'], $annotation->callback);
}
public function testEnable()
{
$annotation = new Crontab();
$annotation->callback = 'execute';
$annotation->collectClass(FooCron::class);
$this->assertTrue($annotation->enable);
$annotation = new Crontab();
$annotation->callback = 'execute';
$annotation->enable = 'true';
$annotation->collectClass(FooCron::class);
$this->assertTrue($annotation->enable);
$annotation = new Crontab();
$annotation->callback = 'execute';
$annotation->enable = 'isEnable';
$annotation->collectClass(FooCron::class);
$this->assertEquals([FooCron::class, 'isEnable'], $annotation->enable);
}
public function testCollectMethod()
{
$annotation = new Crontab();
$annotation->collectMethod(FooCron::class, 'cron');
$this->assertSame(FooCron::class . '::cron', $annotation->name);
$this->assertSame([FooCron::class, 'cron'], $annotation->callback);
}
}