|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Functional; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; |
|
6
|
|
|
use Task\SchedulerInterface; |
|
7
|
|
|
use Task\Storage\StorageInterface; |
|
8
|
|
|
use Task\Task; |
|
9
|
|
|
|
|
10
|
|
|
class Test extends KernelTestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var SchedulerInterface |
|
14
|
|
|
*/ |
|
15
|
|
|
private $scheduler; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var StorageInterface |
|
19
|
|
|
*/ |
|
20
|
|
|
private $storage; |
|
21
|
|
|
|
|
22
|
|
|
protected function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
parent::setUp(); |
|
25
|
|
|
|
|
26
|
|
|
$this->bootKernel(); |
|
27
|
|
|
$this->scheduler = self::$kernel->getContainer()->get('task.scheduler'); |
|
28
|
|
|
$this->storage = self::$kernel->getContainer()->get('task.storage'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testSchedule() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->scheduler->schedule(new Task('test', 'workload')); |
|
34
|
|
|
|
|
35
|
|
|
$scheduled = $this->storage->findScheduled(); |
|
36
|
|
|
$this->assertCount(1, $scheduled); |
|
37
|
|
|
$this->assertEquals('test', $scheduled[0]->getTaskName()); |
|
38
|
|
|
$this->assertEquals('workload', $scheduled[0]->getWorkload()); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testRun() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->scheduler->schedule(new Task('test', 'workload')); |
|
44
|
|
|
$this->scheduler->run(); |
|
45
|
|
|
|
|
46
|
|
|
$scheduled = $this->storage->findScheduled(); |
|
47
|
|
|
$this->assertCount(0, $scheduled); |
|
48
|
|
|
|
|
49
|
|
|
$all = $this->storage->findAll(); |
|
|
|
|
|
|
50
|
|
|
$this->assertCount(1, $all); |
|
51
|
|
|
$this->assertEquals('test', $all[0]->getTaskName()); |
|
52
|
|
|
$this->assertEquals('workload', $all[0]->getWorkload()); |
|
53
|
|
|
$this->assertTrue($all[0]->isCompleted()); |
|
54
|
|
|
$this->assertEquals('daolkrow', $all[0]->getResult()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
// TODO daily |
|
58
|
|
|
} |
|
59
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.