Completed
Push — master ( c5a2a9...e04029 )
by Dmitry
03:31
created

Test::setup()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 8
nop 0
crap 20
1
<?php
2
3
namespace Basis;
4
5
use PHPUnit\Framework\TestCase;
6
use Tarantool\Mapper\Mapper;
7
8
class Test extends TestCase
9
{
10
    public function setup()
11
    {
12
        $root = getcwd();
13
14
        $service = getenv('SERVICE_NAME') ?: basename($root);
15
        $host = getenv('TARANTOOL_SERVICE_HOST') ?: '127.0.0.1';
16
        $port = getenv('TARANTOOL_SERVICE_PORT') ?: '3302';
17
18
        $this->app = new Application($root);
0 ignored issues
show
Bug introduced by
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
19
        $this->get(Config::class)['service'] = $service;
20
        $this->get(Config::class)['tarantool'] = "tcp://$host:$port";
21
        $this->dispatch('tarantool.migrate');
22
    }
23
24
    public function dispatch($job, $params = [])
25
    {
26
        return $this->app->dispatch($job, $params);
27
    }
28
29
    public function get($class)
30
    {
31
        return $this->app->get($class);
32
    }
33
34
    public function getMapper()
35
    {
36
        return $this->get(Mapper::class);
37
    }
38
39
    public function find($space, $params = [])
40
    {
41
        return $this->getMapper()->find($space, $params);
42
    }
43
44
    public function findOne($space, $params = [])
45
    {
46
        return $this->getMapper()->findOne($space, $params);
47
    }
48
}
49