-
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support custom "Last updated at" label
- Loading branch information
Showing
7 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Knuckles\Scribe\Tests\Unit; | ||
|
||
use Knuckles\Scribe\Tools\DocumentationConfig; | ||
use Knuckles\Scribe\Writing\HtmlWriter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HtmlWriterTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function sets_last_updated_correctly() | ||
{ | ||
$config = ["base_url" => "http://local.test", "title" => "API Docs"]; | ||
$config["last_updated"] = ''; | ||
$writer = new HtmlWriter(new DocumentationConfig($config)); | ||
$lastUpdated = $writer->getMetadata()["last_updated"]; | ||
$this->assertEquals('', $lastUpdated); | ||
|
||
$config["last_updated"] = "Last updated on {date:l}"; | ||
$writer = new HtmlWriter(new DocumentationConfig($config)); | ||
$lastUpdated = $writer->getMetadata()["last_updated"]; | ||
$today = date("l"); | ||
$this->assertEquals("Last updated on $today", $lastUpdated); | ||
|
||
$config["last_updated"] = "Last updated on {date:l, jS F} (Git commit {git:short})"; | ||
$writer = new HtmlWriter(new DocumentationConfig($config)); | ||
$lastUpdated = $writer->getMetadata()["last_updated"]; | ||
$date = date("l, jS F"); | ||
$commit = trim(shell_exec('git rev-parse --short HEAD')); | ||
$this->assertEquals("Last updated on $date (Git commit $commit)", $lastUpdated); | ||
} | ||
} |