Completed
Push — master ( b1fdaf...86da06 )
by Dmitry
06:20
created

Test   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 3
dl 0
loc 56
ccs 0
cts 43
cp 0
rs 10
c 0
b 0
f 0

9 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
A findOrFail() 0 4 1
A findOrCreate() 0 4 1
1
<?php
2
3
namespace Basis;
4
5
use PHPUnit\Framework\TestCase;
6
use Tarantool\Mapper\Mapper;
7
use Tarantool\Mapper\Entity;
8
9
abstract class Test extends TestCase
10
{
11
    public function setup()
12
    {
13
        $root = getcwd();
14
15
        $service = getenv('SERVICE_NAME') ?: basename($root);
16
        $host = getenv('TARANTOOL_SERVICE_HOST') ?: '127.0.0.1';
17
        $port = getenv('TARANTOOL_SERVICE_PORT') ?: '3302';
18
19
        $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...
20
        $this->get(Config::class)['service'] = $service;
21
        $this->get(Config::class)['tarantool'] = "tcp://$host:$port";
22
        $this->dispatch('tarantool.migrate');
23
    }
24
25
    public function tearDown()
26
    {
27
        $this->dispatch('tarantool.clear');
28
    }
29
30
    public function dispatch(string $job, array $params = [])
31
    {
32
        return $this->app->dispatch($job, $params);
33
    }
34
35
    public function get(string $class)
36
    {
37
        return $this->app->get($class);
38
    }
39
40
    public function getMapper() : Mapper
41
    {
42
        return $this->get(Mapper::class);
43
    }
44
45
    public function find(string $space, array $params = []) : array
46
    {
47
        return $this->getMapper()->find($space, $params);
48
    }
49
50
    public function findOne(string $space, array $params = []) : Entity
51
    {
52
        return $this->getMapper()->findOne($space, $params);
53
    }
54
55
    public function findOrFail(string $space, array $params = []) : Entity
56
    {
57
        return $this->getMapper()->findOrFail($space, $params);
58
    }
59
60
    public function findOrCreate(string $space, array $params = []) : Entity
61
    {
62
        return $this->getMapper()->findOrCreate($space, $params);
63
    }
64
}
65