Passed
Push — master ( 343fce...2eecbd )
by Victor
02:39
created

ContextTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testGetAttributeShouldReturnGivenDefaultValueIfAttributeDoesNotExist() 0 3 1
A testGetAttributeShouldReturnValueIfAttributeExists() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Tests;
5
6
use PHPUnit\Framework\TestCase;
7
use Shoot\Shoot\Context;
8
9
final class ContextTest extends TestCase
10
{
11
    /** @var Context */
12
    private $context;
13
14
    /**
15
     * @return void
16
     */
17
    protected function setUp()
18
    {
19
        $this->context = new Context([
20
            'null_attribute' => null,
21
            'string_attribute' => 'value',
22
        ]);
23
    }
24
25
    /**
26
     * @return void
27
     */
28
    public function testGetAttributeShouldReturnGivenDefaultValueIfAttributeDoesNotExist()
29
    {
30
        $this->assertSame('default', $this->context->getAttribute('non_existing_attribute', 'default'));
31
    }
32
33
    /**
34
     * @return void
35
     */
36
    public function testGetAttributeShouldReturnValueIfAttributeExists()
37
    {
38
        $this->assertSame('value', $this->context->getAttribute('string_attribute'));
39
    }
40
}
41