GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — dev ( fb9f08...0e0077 )
by Андрей
10:45 queued 05:08
created

testTranslateVariablesMultiVariables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
/**
3
 * @link    https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\PhpUnitTest\Util;
7
8
use PHPUnit_Framework_TestCase as TestCase;
9
use OldTown\Workflow\TransientVars\BaseTransientVars;
10
use OldTown\PropertySet\PropertySetInterface;
11
use OldTown\Workflow\Util\DefaultVariableResolver;
12
use OldTown\Workflow\PhpUnit\Data\VariableResolver\TestObject;
13
14
/**
15
 * Class DefaultVariableResolverTest
16
 *
17
 * @package OldTown\Workflow\PhpUnitTest\Util
18
 */
19
class  DefaultVariableResolverTest extends TestCase
20
{
21
    /**
22
     * @var DefaultVariableResolver
23
     */
24
    protected $variableResolver;
25
26
    /**
27
     * @return void
28
     */
29
    protected function setUp()
30
    {
31
        $this->variableResolver = new DefaultVariableResolver();
32
        parent::setUp();
33
    }
34
35
    /**
36
     * Проверка получения значения из TransientVars.
37
     *
38
     */
39
    public function testTranslateVariablesResolveFromTransientVars()
40
    {
41
        $tv = new BaseTransientVars();
42
        /** @var PropertySetInterface $ps */
43
        $ps = $this->getMock(PropertySetInterface::class);
44
45
        $var = '${testVariable}';
46
47
        $expected = new \stdClass();
48
49
        $tv['testVariable'] = $expected;
50
        $actual = $this->variableResolver->translateVariables($var, $tv, $ps);
51
52
        static::assertTrue($expected === $actual, $actual);
53
    }
54
55
    /**
56
     * Проверка замены нескольких переменных из TransientVars
57
     */
58
    public function testTranslateVariablesMultiVariables()
59
    {
60
        $str = 'text1 ${var1} text2 ${var2} ${var3}';
61
62
        $tv = new BaseTransientVars();
63
        $tv['var1'] = 'var1_value';
64
        $tv['var2'] = 'var2_value';
65
        $tv['var3'] = 'var3_value';
66
67
        /** @var PropertySetInterface $ps */
68
        $ps = $this->getMock(PropertySetInterface::class);
69
70
        $actual = $this->variableResolver->translateVariables($str, $tv, $ps);
71
72
        static::assertEquals('text1 var1_value text2 var2_value var3_value', $actual);
73
    }
74
75
76
    /**
77
     * Проверка работы с методами
78
     */
79
    public function testTranslateVariablesObjectMethod()
80
    {
81
        $tv = new BaseTransientVars();
82
        $tv['obj'] = new TestObject();
83
84
85
        /** @var PropertySetInterface $ps */
86
        $ps = $this->getMock(PropertySetInterface::class);
87
88
        $actual = $this->variableResolver->translateVariables('${obj.value1.value2}', $tv, $ps);
89
90
        static::assertEquals($tv['obj']->getValue1()->getValue2(), $actual);
91
    }
92
}
93