Completed
Push — master ( e04029...518266 )
by Dmitry
03:33
created

Test   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 2
dl 0
loc 46
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 13 4
A tearDown() 0 4 1
A dispatch() 0 4 1
A get() 0 4 1
A getMapper() 0 4 1
A find() 0 4 1
A findOne() 0 4 1
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 tearDown()
25
    {
26
        $this->dispatch('tarantool.clear');
27
    }
28
29
    public function dispatch($job, $params = [])
30
    {
31
        return $this->app->dispatch($job, $params);
32
    }
33
34
    public function get($class)
35
    {
36
        return $this->app->get($class);
37
    }
38
39
    public function getMapper()
40
    {
41
        return $this->get(Mapper::class);
42
    }
43
44
    public function find($space, $params = [])
45
    {
46
        return $this->getMapper()->find($space, $params);
47
    }
48
49
    public function findOne($space, $params = [])
50
    {
51
        return $this->getMapper()->findOne($space, $params);
52
    }
53
}
54