-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHasConfigurationTest.php
More file actions
67 lines (52 loc) · 1.77 KB
/
Copy pathHasConfigurationTest.php
File metadata and controls
67 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace BabenkoIvan\FluentArray\Tests;
use BabenkoIvan\FluentArray\FluentArray;
use BabenkoIvan\FluentArray\HasConfiguration;
use PHPUnit\Framework\TestCase;
class HasConfigurationTest extends TestCase
{
public function testGlobalConfigMethod()
{
$configurable = new class
{
use HasConfiguration;
};
$this->assertInstanceOf(FluentArray::class, $configurable::globalConfig());
$newGlobalConfig = (new FluentArray())
->set('foo', 1)
->set('bar', 2);
$configurable::globalConfig($newGlobalConfig);
$this->assertSame(1, $configurable::globalConfig()->get('foo'));
$this->assertSame(2, $configurable::globalConfig()->get('bar'));
}
public function testConfigMethod()
{
$configurable = new class
{
use HasConfiguration;
};
$this->assertInstanceOf(FluentArray::class, $configurable->config());
$newConfig = (new FluentArray())
->set('foo', 1)
->set('bar', 2);
$configurable->config($newConfig);
$this->assertSame(1, $configurable->config()->get('foo'));
$this->assertSame(2, $configurable->config()->get('bar'));
}
public function testDefaultConfig()
{
$configurable = new class
{
use HasConfiguration;
protected static function defaultConfig()
{
return (new FluentArray())
->set('foo', 1)
->set('bar', 2);
}
};
$this->assertInstanceOf(FluentArray::class, $configurable->config());
$this->assertSame(1, $configurable->config()->get('foo'));
$this->assertSame(2, $configurable->config()->get('bar'));
}
}