Completed
Push — master ( a9d3b9...e09e3d )
by Kirill
03:27
created

LoadActionData   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 47
ccs 0
cts 33
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 44 1
1
<?php
2
3
namespace AppBundle\DataFixtures\ORM;
4
5
use AppBundle\Entity\Action;
6
use AppBundle\Entity\Device;
7
use AppBundle\Entity\VarHook;
8
use AppBundle\Entity\Variable;
9
use Doctrine\Common\DataFixtures\FixtureInterface;
10
use Doctrine\Common\Persistence\ObjectManager;
11
12
class LoadActionData implements FixtureInterface
13
{
14
    public function load(ObjectManager $manager)
15
    {
16
        $variable = new Variable();
17
18
        $variable->setName('hooktest');
19
        $variable->setDescription('test temperature metric');
20
        $variable->setSource('internal');
21
        $variable->setParser('Simple');
22
        $variable->setValue('20');
23
        $variable->needHistory = true;
24
        $variable->needSync = false;
25
26
        $manager->persist($variable);
27
28
        $device = new Device();
29
        $device->setAlias('pi.fs');
30
        $device->setName('Filesystem');
31
32
        $manager->persist($device);
33
34
        $action = new Action();
35
36
        $action->setArguments(json_encode(['file'=>'/tmp/testfile.log', 'text'=>'testtext']));
37
        $action->setType('real');
38
        $action->setAlias('file.write');
39
        $action->setDevice($device);
40
        $action->setName("Write file to disk");
41
        $action->setExecutor('FileWriter:write');
42
43
        $manager->persist($action);
44
45
        $varHook = new VarHook();
46
        $varHook->setVariable($variable);
47
        $varHook->setAction($action);
48
        $varHook->setName("Test variable hook");
49
        $varHook->setType("decider");
50
        $varHook->setExecutor("FileWriter:decideTrue");
51
        $varHook->setArguments('{"text":"test text"}');
52
53
        $manager->persist($varHook);
54
55
56
        $manager->flush();
57
    }
58
}
59