Test Failed
Push — master ( 8f2167...5d2217 )
by Georgi
08:27
created

VariablesTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testVariableStorage() 0 24 1
A setUp() 0 5 1
1
<?php
2
3
namespace Epesi\Core\Tests;
4
5
use Orchestra\Testbench\TestCase;
6
use Epesi\Core\System\Models\Variable;
7
8
class VariablesTest extends TestCase
9
{
10
    /**
11
     * Setup the test environment.
12
     */
13
    protected function setUp(): void
14
    {
15
        parent::setUp();
16
17
        Variable::migrate();
18
    }
19
    
20
    public function testVariableStorage()
21
    {
22
        $varString = 'test';
23
        
24
        Variable::memorize('testString', $varString);
25
        
26
        $this->assertEquals($varString, Variable::recall('testString'), 'String variable not stored correctly in database');
27
        
28
        Variable::forget('testString');
29
        
30
        $this->assertEmpty(Variable::recall('testString'), 'String variable not cleared correctly from database');
31
        
32
        $varArray = [
33
                'aa' => 'test1',
34
                'bb' => 'test2'
35
        ];
36
        
37
        Variable::memorize('testArray', $varArray);
38
        
39
        $this->assertEquals($varArray, Variable::recall('testArray'), 'Array variable not stored correctly in database');
40
        
41
        Variable::forget('testArray');
42
        
43
        $this->assertEmpty(Variable::recall('testArray'), 'String variable not cleared correctly from database');
44
    }
45
    
46
47
}