|
2 | 2 |
|
3 | 3 | class ConfigTest extends PHPUnit_Framework_TestCase { |
4 | 4 |
|
5 | | - public function testItemsCanBeSet() |
| 5 | + public $feather; |
| 6 | + |
| 7 | + public function setUp() |
6 | 8 | { |
7 | | - $config = $this->getRepository(); |
| 9 | + $this->feather = Feather\Components\Support\Facade::application(); |
8 | 10 |
|
9 | | - $config->set('name', 'jason'); |
10 | | - $this->assertEquals('jason', $config->get('name')); |
| 11 | + $this->feather['config']->set('test', $this->items()); |
| 12 | + } |
11 | 13 |
|
12 | | - $config->set('person.name', 'jason'); |
13 | | - $this->assertEquals('jason', $config->get('person.name')); |
| 14 | + public function testItemsCanBeSet() |
| 15 | + { |
| 16 | + $this->feather['config']->set('name', 'jason'); |
| 17 | + $this->assertEquals('jason', $this->feather['config']->get('name')); |
14 | 18 |
|
15 | | - $config->set('namespace::person.name', 'jason'); |
16 | | - $this->assertEquals('jason', $config->get('namespace::person.name')); |
| 19 | + $this->feather['config']->set('person.name', 'jason'); |
| 20 | + $this->assertEquals('jason', $this->feather['config']->get('person.name')); |
17 | 21 |
|
18 | | - $config->set('gear: mock person.name', 'jason'); |
19 | | - $this->assertEquals('jason', $config->get('gear: mock person.name')); |
| 22 | + $this->feather['config']->set('namespace::person.name', 'jason'); |
| 23 | + $this->assertEquals('jason', $this->feather['config']->get('namespace::person.name')); |
20 | 24 |
|
21 | | - $config->set('theme: mock person.name', 'jason'); |
22 | | - $this->assertEquals('jason', $config->get('theme: mock person.name')); |
| 25 | + $this->feather['config']->set('gear: mock person.name', 'jason'); |
| 26 | + $this->assertEquals('jason', $this->feather['config']->get('gear: mock person.name')); |
| 27 | + |
| 28 | + $this->feather['config']->set('theme: mock person.name', 'jason'); |
| 29 | + $this->assertEquals('jason', $this->feather['config']->get('theme: mock person.name')); |
23 | 30 | } |
24 | 31 |
|
25 | 32 | public function testGetBasicItems() |
26 | 33 | { |
27 | | - $config = $this->getRepository(); |
28 | | - |
29 | | - $this->assertEquals('bar', $config->get('test.foo')); |
30 | | - $this->assertEquals('orange', $config->get('test.apple')); |
| 34 | + $this->assertEquals('bar', $this->feather['config']->get('test.foo')); |
| 35 | + $this->assertEquals('orange', $this->feather['config']->get('test.apple')); |
31 | 36 | } |
32 | 37 |
|
33 | 38 | public function testEntireArrayCanBeReturned() |
34 | 39 | { |
35 | | - $config = $this->getRepository(); |
36 | | - |
37 | | - $this->assertEquals($this->getItems(), $config->get('test')); |
| 40 | + $this->assertEquals($this->items(), $this->feather['config']->get('test')); |
38 | 41 | } |
39 | 42 |
|
40 | 43 | public function testCheckItemExistance() |
41 | 44 | { |
42 | | - $config = $this->getRepository(); |
43 | | - |
44 | | - $config->set('foo', 'bar'); |
45 | | - $this->assertTrue($config->has('foo')); |
| 45 | + $this->feather['config']->set('foo', 'bar'); |
46 | 46 |
|
47 | | - $this->assertTrue(!$config->has('apple')); |
| 47 | + $this->assertTrue($this->feather['config']->has('foo')); |
| 48 | + $this->assertTrue(!$this->feather['config']->has('apple')); |
48 | 49 | } |
49 | 50 |
|
50 | 51 | public function testItemsCanBeSaved() |
51 | 52 | { |
52 | | - $config = $this->getRepository(); |
| 53 | + $this->feather['config']->set('feather: db.test', 'foobar'); |
| 54 | + $this->feather['config']->save('feather: db.test'); |
53 | 55 |
|
54 | | - $config->set('feather: db.test', 'foobar'); |
55 | | - $config->save('feather: db.test'); |
| 56 | + $this->feather['config']->reload(); |
56 | 57 |
|
57 | | - $config->reload(); |
| 58 | + $this->assertEquals('foobar', $this->feather['config']->get('feather: db.test')); |
58 | 59 |
|
59 | | - $this->assertEquals('foobar', $config->get('feather: db.test')); |
60 | | - |
61 | | - $config->delete('feather: db.test'); |
| 60 | + $this->feather['config']->delete('feather: db.test'); |
62 | 61 | } |
63 | 62 |
|
64 | 63 | public function testItemsCanBeDeleted() |
65 | 64 | { |
66 | | - $config = $this->getRepository(); |
67 | | - |
68 | | - $config->set('feather: db.test', 'foobar'); |
69 | | - $config->save('feather: db.test'); |
70 | | - |
71 | | - $config->reload(); |
72 | | - |
73 | | - $config->delete('feather: db.test'); |
| 65 | + $this->feather['config']->set('feather: db.test', 'foobar'); |
| 66 | + $this->feather['config']->save('feather: db.test'); |
74 | 67 |
|
75 | | - $config->reload(); |
76 | | - |
77 | | - $this->assertEquals(null, $config->get('feather: db.test')); |
78 | | - } |
79 | | - |
80 | | - private function getRepository() |
81 | | - { |
82 | | - $feather = Feather\Components\Support\Facade::application(); |
| 68 | + $this->feather['config']->reload(); |
83 | 69 |
|
84 | | - $config = $feather['config']; |
| 70 | + $this->feather['config']->delete('feather: db.test'); |
85 | 71 |
|
86 | | - $config->set('test', $this->getItems()); |
| 72 | + $this->feather['config']->reload(); |
87 | 73 |
|
88 | | - return $config; |
| 74 | + $this->assertEquals(null, $this->feather['config']->get('feather: db.test')); |
89 | 75 | } |
90 | 76 |
|
91 | | - private function getItems() |
| 77 | + public function items() |
92 | 78 | { |
93 | 79 | return array('foo' => 'bar', 'apple' => 'orange'); |
94 | 80 | } |
|
0 commit comments