From 376aede1ba61a2fb08a49048b08b2cadb24b041b Mon Sep 17 00:00:00 2001 From: brabli <67018167+brabli@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:07:44 +0000 Subject: [PATCH] Add tests --- tests/Model/MetadataTest.php | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/Model/MetadataTest.php 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); + } +} +