|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Kore\DataObject; |
| 4 | + |
| 5 | +class TestStruct extends Struct { |
| 6 | + public $property; |
| 7 | +} |
| 8 | + |
| 9 | +/** |
| 10 | + * @covers \Kagency\CouchdbEndpoint\Struct |
| 11 | + */ |
| 12 | +class StructTest extends \PHPUnit_Framework_TestCase |
| 13 | +{ |
| 14 | + public function testGetValue() |
| 15 | + { |
| 16 | + $struct = new TestStruct(); |
| 17 | + |
| 18 | + $this->assertNull($struct->property); |
| 19 | + } |
| 20 | + |
| 21 | + public function testConstructor() |
| 22 | + { |
| 23 | + $struct = new TestStruct( |
| 24 | + array( |
| 25 | + 'property' => 42, |
| 26 | + ) |
| 27 | + ); |
| 28 | + |
| 29 | + $this->assertSame(42, $struct->property); |
| 30 | + } |
| 31 | + |
| 32 | + public function testSetValue() |
| 33 | + { |
| 34 | + $struct = new TestStruct(); |
| 35 | + $struct->property = 42; |
| 36 | + |
| 37 | + $this->assertSame(42, $struct->property); |
| 38 | + } |
| 39 | + |
| 40 | + public function testUnsetValue() |
| 41 | + { |
| 42 | + $struct = new TestStruct(); |
| 43 | + $struct->property = 42; |
| 44 | + unset($struct->property); |
| 45 | + |
| 46 | + $this->assertFalse(isset($struct->property)); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * @expectedException \OutOfRangeException |
| 51 | + */ |
| 52 | + public function testGetUnknownValue() |
| 53 | + { |
| 54 | + $struct = new TestStruct(); |
| 55 | + |
| 56 | + $this->assertNull($struct->unknown); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @expectedException \OutOfRangeException |
| 61 | + */ |
| 62 | + public function testConstructorUnknwonValue() |
| 63 | + { |
| 64 | + $struct = new TestStruct( |
| 65 | + array( |
| 66 | + 'unknown' => 42, |
| 67 | + ) |
| 68 | + ); |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * @expectedException \OutOfRangeException |
| 73 | + */ |
| 74 | + public function testSetUnknownValue() |
| 75 | + { |
| 76 | + $struct = new TestStruct(); |
| 77 | + $struct->unknown = 42; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * @expectedException \OutOfRangeException |
| 82 | + */ |
| 83 | + public function testUnsetUnknownValue() |
| 84 | + { |
| 85 | + $struct = new TestStruct(); |
| 86 | + unset($struct->unknown); |
| 87 | + } |
| 88 | +} |
0 commit comments