Completed
Push — master ( 2a89ae...63e97e )
by Wachter
08:08
created

Test::testRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4286
cc 1
eloc 11
nc 1
nop 0
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();
0 ignored issues
show
Bug introduced by
The method findAll() does not seem to exist on object<Task\Storage\StorageInterface>.

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.

Loading history...
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