scratch – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 namespace Alchemy\Tests\BinaryDriver;
4  
5 use Alchemy\BinaryDriver\Configuration;
6  
7 class ConfigurationTest extends \PHPUnit_Framework_TestCase
8 {
9 public function testArrayAccessImplementation()
10 {
11 $configuration = new Configuration(array('key' => 'value'));
12  
13 $this->assertTrue(isset($configuration['key']));
14 $this->assertEquals('value', $configuration['key']);
15  
16 $this->assertFalse(isset($configuration['key2']));
17 unset($configuration['key']);
18 $this->assertFalse(isset($configuration['key']));
19  
20 $configuration['key2'] = 'value2';
21 $this->assertTrue(isset($configuration['key2']));
22 $this->assertEquals('value2', $configuration['key2']);
23 }
24  
25 public function testGetOnNonExistentKeyShouldReturnDefaultValue()
26 {
27 $conf = new Configuration();
28 $this->assertEquals('booba', $conf->get('hooba', 'booba'));
29 $this->assertEquals(null, $conf->get('hooba'));
30 }
31  
32 public function testSetHasGetRemove()
33 {
34 $configuration = new Configuration(array('key' => 'value'));
35  
36 $this->assertTrue($configuration->has('key'));
37 $this->assertEquals('value', $configuration->get('key'));
38  
39 $this->assertFalse($configuration->has('key2'));
40 $configuration->remove('key');
41 $this->assertFalse($configuration->has('key'));
42  
43 $configuration->set('key2', 'value2');
44 $this->assertTrue($configuration->has('key2'));
45 $this->assertEquals('value2', $configuration->get('key2'));
46 }
47  
48 public function testIterator()
49 {
50 $data = array(
51 'key1' => 'value1',
52 'key2' => 'value2',
53 'key3' => 'value3',
54 );
55  
56 $captured = array();
57 $conf = new Configuration($data);
58  
59 foreach ($conf as $key => $value) {
60 $captured[$key] = $value;
61 }
62  
63 $this->assertEquals($data, $captured);
64 }
65  
66 public function testAll()
67 {
68 $data = array(
69 'key1' => 'value1',
70 'key2' => 'value2',
71 'key3' => 'value3',
72 );
73  
74 $conf = new Configuration($data);
75 $this->assertEquals($data, $conf->all());
76 }
77  
78 }