diff --git a/tests/Content/MemoryContentStorageHandlerTest.php b/tests/Content/MemoryContentStorageHandlerTest.php index 6f63f07cf4..561fe9a8d7 100644 --- a/tests/Content/MemoryContentStorageHandlerTest.php +++ b/tests/Content/MemoryContentStorageHandlerTest.php @@ -7,11 +7,18 @@ /** * @coversDefaultClass Kirby\Content\MemoryContentStorageHandler * @covers ::__construct + * @covers ::cacheId */ class MemoryContentStorageHandlerTest extends TestCase { protected $storage; + /** + * @covers ::create + * @covers ::delete + * @covers ::exists + * @covers ::write + */ public function assertCreateAndDelete(VersionId $versionId, Language $language): void { $this->storage->create($versionId, $language, []); @@ -23,6 +30,12 @@ public function assertCreateAndDelete(VersionId $versionId, Language $language): $this->assertFalse($this->storage->exists($versionId, $language)); } + /** + * @covers ::create + * @covers ::exists + * @covers ::read + * @covers ::write + */ public function assertCreateAndRead(VersionId $versionId, Language $language): void { $fields = [ @@ -36,6 +49,30 @@ public function assertCreateAndRead(VersionId $versionId, Language $language): v $this->assertSame($fields, $this->storage->read($versionId, $language)); } + /** + * @covers ::create + * @covers ::exists + * @covers ::read + * @covers ::update + * @covers ::write + */ + public function assertCreateAndUpdate(VersionId $versionId, Language $language): void + { + $fields = [ + 'title' => 'Foo', + 'text' => 'Bar' + ]; + + $this->storage->create($versionId, $language, []); + + $this->assertSame([], $this->storage->read($versionId, $language)); + + $this->storage->update($versionId, $language, $fields); + + $this->assertTrue($this->storage->exists($versionId, $language)); + $this->assertSame($fields, $this->storage->read($versionId, $language)); + } + public function setUpMultiLanguage(): void { parent::setUpMultiLanguage(); @@ -108,6 +145,7 @@ public function testCreateAndReadPublishedSingleLang() /** * @covers ::delete + * @covers ::exists */ public function testDeleteNonExisting() { @@ -286,4 +324,30 @@ public function testTouchSingleLang() $this->assertGreaterThanOrEqual($time, $this->storage->modified($versionId, $language)); } + + /** + * @covers ::update + */ + public function testUpdateMultiLang() + { + $this->setUpMultiLanguage(); + + $versionId = VersionId::changes(); + $language = $this->app->language('en'); + + $this->assertCreateAndUpdate($versionId, $language); + } + + /** + * @covers ::update + */ + public function testUpdateSingleLang() + { + $this->setUpSingleLanguage(); + + $versionId = VersionId::changes(); + $language = Language::single(); + + $this->assertCreateAndUpdate($versionId, $language); + } }