diff --git a/CHANGELOG.md b/CHANGELOG.md index e904c0e..fb39fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.4 - WIP +- Adding `hasTags()`, `tagListAsString()`, `tagListAsArray()` methods for stories + ## 1.0.3 - 2025-09-29 - Adding new parameter for duplicating space (for adding the space in the organization) - Adding `update()` method for Space endpoint diff --git a/src/Data/StoryBaseData.php b/src/Data/StoryBaseData.php index 336feba..304359c 100644 --- a/src/Data/StoryBaseData.php +++ b/src/Data/StoryBaseData.php @@ -18,4 +18,26 @@ public function hasWorkflowStage(): bool $workflowStageId = $this->getInt('stage.workflow_stage_id', 0); return $workflowStageId > 0; } + + public function hasTags(): bool + { + $tags = $this->getArray('tag_list', []); + return $tags !== []; + } + + public function tagListAsString(): string + { + $tags = $this->getArray('tag_list', []); + return implode(", ", $tags); + } + + /** + * Returns the list of tags as array. + * + * @return array + */ + public function tagListAsArray(): array + { + return $this->getArray('tag_list', []); + } } diff --git a/tests/Feature/Data/one-story.json b/tests/Feature/Data/one-story.json index 6ff76bc..562c478 100644 --- a/tests/Feature/Data/one-story.json +++ b/tests/Feature/Data/one-story.json @@ -13,7 +13,7 @@ "full_slug": "posts/my-third-post", "sort_by_date": null, "position": 0, - "tag_list": [], + "tag_list": ["tag1","tag2"], "is_startpage": false, "parent_id": 440448337, "meta_data": null, diff --git a/tests/Feature/StoryTest.php b/tests/Feature/StoryTest.php index d5917e2..7d2765e 100644 --- a/tests/Feature/StoryTest.php +++ b/tests/Feature/StoryTest.php @@ -30,6 +30,8 @@ ->toBe("My third post") ->and($storyblokData->name())->toBe("My third post") ->and($storyblokData->createdAt())->toBe("2024-02-08") + ->and($storyblokData->tagListAsArray())->toBe(["tag1", "tag2"]) + ->and($storyblokData->tagListAsString())->toBe("tag1, tag2") ->and($storyblokResponse->getResponseStatusCode())->toBe(200); expect(function () use ($storyApi): void {