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

Test   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 0
loc 41
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 13 4
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 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