Skip to content

Commit

Permalink
Add ::contentFile method
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Jun 5, 2024
1 parent 7496a1d commit dd746cb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Content/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ public function content(string $language = 'default'): Content
);
}

/**
* Provides simplified access to the absolute content file path.
* This should stay an internal method and be removed as soon as
* the dependency on file storage methods is resolved more clearly.
*
* @internal
*/
public function contentFile(string $language = 'default'): string
{
return $this->model->storage()->contentFile($this->id, $this->language($language));
}

/**
* Creates a new version for the given language
*
Expand Down
31 changes: 31 additions & 0 deletions tests/Content/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,37 @@ public function testContentSingleLanguage(): void
$this->assertSame('Test', $version->content()->get('title')->value());
}

/**
* @covers ::contentFile
*/
public function testContentFileMultiLanguage(): void
{
$this->setUpMultiLanguage();

$version = new Version(
model: $this->model,
id: VersionId::published()
);

$this->assertSame($this->model->root() . '/article.en.txt', $version->contentFile());
$this->assertSame($this->model->root() . '/article.de.txt', $version->contentFile('de'));
}

/**
* @covers ::contentFile
*/
public function testContentFileSingleLanguage(): void
{
$this->setUpSingleLanguage();

$version = new Version(
model: $this->model,
id: VersionId::published()
);

$this->assertSame($this->model->root() . '/article.txt', $version->contentFile());
}

/**
* @covers ::create
*/
Expand Down

0 comments on commit dd746cb

Please sign in to comment.