Completed
Push — master ( 463d73...47ba96 )
by Gerrit
02:04
created

ArgumentContextTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 40
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldContainContextualData() 0 32 1
1
<?php
2
/**
3
 * Copyright (C) 2017  Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks\SymfonyGenerics\Tests\Unit\Arguments;
12
13
use PHPUnit\Framework\TestCase;
14
use Addiks\SymfonyGenerics\Arguments\ArgumentContext;
15
use stdClass;
16
17
final class ArgumentContextTest extends TestCase
18
{
19
20
    /**
21
     * @test
22
     */
23
    public function shouldContainContextualData()
24
    {
25
        $context = new ArgumentContext();
26
27
        $this->assertFalse($context->has("foo"));
28
        $this->assertFalse($context->has("bar"));
29
        $this->assertFalse($context->has("baz"));
30
31
        $context->set("foo", 1234);
32
33
        $this->assertTrue($context->has("foo"));
34
        $this->assertFalse($context->has("bar"));
35
        $this->assertFalse($context->has("baz"));
36
        $this->assertEquals(1234, $context->get("foo"));
37
38
        $context->set("bar", ['lorem' => 'ipsum', 'dolor' => 'amet']);
39
40
        $this->assertTrue($context->has("foo"));
41
        $this->assertTrue($context->has("bar"));
42
        $this->assertFalse($context->has("baz"));
43
        $this->assertEquals(1234, $context->get("foo"));
44
        $this->assertEquals(['lorem' => 'ipsum', 'dolor' => 'amet'], $context->get("bar"));
45
46
        $context->set("baz", new stdClass());
47
48
        $this->assertTrue($context->has("foo"));
49
        $this->assertTrue($context->has("bar"));
50
        $this->assertTrue($context->has("baz"));
51
        $this->assertEquals(1234, $context->get("foo"));
52
        $this->assertEquals(['lorem' => 'ipsum', 'dolor' => 'amet'], $context->get("bar"));
53
        $this->assertEquals(new stdClass(), $context->get("baz"));
54
    }
55
56
}
57