-
-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
143 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Revisions; | ||
|
||
use Carbon\Carbon; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Statamic\Facades\Revision; | ||
use Statamic\Revisions\Revisable; | ||
use Tests\PreventSavingStacheItemsToDisk; | ||
use Tests\TestCase; | ||
|
||
class RevisableTest extends TestCase | ||
{ | ||
use PreventSavingStacheItemsToDisk; | ||
|
||
private $revisable; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
config(['statamic.revisions' => [ | ||
'enabled' => true, | ||
'path' => __DIR__.'/__fixtures__', | ||
]]); | ||
|
||
$this->revisable = new class | ||
{ | ||
use Revisable; | ||
|
||
protected function revisionKey() | ||
{ | ||
return '123'; | ||
} | ||
|
||
protected function revisionAttributes() | ||
{ | ||
return [ | ||
'id' => 123 | ||
]; | ||
} | ||
|
||
public function makeFromRevision($revision) | ||
{ | ||
return new self; | ||
} | ||
}; | ||
} | ||
|
||
#[Test] | ||
public function has_revisions() | ||
{ | ||
$this->assertTrue($this->revisable->hasRevisions()); | ||
} | ||
|
||
#[Test] | ||
public function sets_publish_at_from_options() | ||
{ | ||
Carbon::setTestNow($now = now()); | ||
|
||
$this->revisable->createRevision(['publish_at' => $now]); | ||
|
||
$revision = $this->revisable->latestRevision(); | ||
Revision::delete($revision); | ||
|
||
$this->assertEquals($revision->publishAt()->timestamp, $now->timestamp); | ||
} | ||
} |
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,3 @@ | ||
date: 1553546421 | ||
attributes: | ||
date: 1740528000 |
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,4 @@ | ||
date: 1553546422 | ||
publish_at: 1553644800 | ||
attributes: | ||
date: 1740528000 |
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,3 @@ | ||
date: 1553546423 | ||
attributes: | ||
id: 123 |
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