diff --git a/tests/Model/MetadataTest.php b/tests/Model/MetadataTest.php new file mode 100644 index 0000000..f9a3b34 --- /dev/null +++ b/tests/Model/MetadataTest.php @@ -0,0 +1,64 @@ +metadata = new Metadata($array); + } + + public function testGetReturnsSetValue(): void + { + $value = 'brad woz ere'; + $this->metadata->set('key', $value); + $result = $this->metadata->get('key'); + $this->assertSame($value, $result); + } + + public function testGetThrowsWhenKeyNotSet(): void + { + $this->expectException(MissingKeyException::class); + $this->metadata->get('missing'); + } + + public function testValueIsOverwritten(): void + { + $key = 'key'; + $valueA = 'meta'; + $valueB = 'data'; + + $this->metadata->set($key, $valueA); + $result = $this->metadata->get($key); + $this->assertSame($valueA, $result); + + $this->metadata->set($key, $valueB); + $result = $this->metadata->get($key); + $this->assertSame($valueB, $result); + } + + public function testHasReturnsTrueWhenKeyIsSet(): void + { + $key = 'null'; + $this->metadata->set($key, null); + $result = $this->metadata->has($key); + $this->assertTrue($result); + } + + public function testHasReturnsFalseWhenKeyIsNotSet(): void + { + $result = $this->metadata->has('missing'); + $this->assertFalse($result); + } +} +