-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
1 parent
85c8bfb
commit ad72b44
Showing
3 changed files
with
83 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace Kirby\Panel\Controller; | ||
|
||
use Kirby\Cms\Page; | ||
use Kirby\Data\Data; | ||
use Kirby\TestCase; | ||
|
||
class ChangesTest extends TestCase | ||
{ | ||
public const TMP = KIRBY_TMP_DIR . '/Panel.Controller.Changes'; | ||
public Page $page; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->setUpTmp(); | ||
$this->setUpSingleLanguage(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
$this->tearDownTmp(); | ||
} | ||
|
||
public function testDiscard() | ||
{ | ||
Data::write($file = $this->model->root() . '/_changes/article.txt', []); | ||
|
||
$response = Changes::discard($this->model); | ||
|
||
$this->assertSame(['status' => 'ok'], $response); | ||
|
||
$this->assertFileDoesNotExist($file); | ||
} | ||
|
||
public function testPublish() | ||
{ | ||
Data::write($this->model->root() . '/article.txt', []); | ||
Data::write($file = $this->model->root() . '/_changes/article.txt', []); | ||
|
||
$response = Changes::publish($this->model, [ | ||
'title' => 'Test' | ||
]); | ||
|
||
$this->assertSame(['status' => 'ok'], $response); | ||
|
||
// the changes should be gone now | ||
$this->assertFileDoesNotExist($file); | ||
|
||
// and the content file should be updated with the input | ||
$published = Data::read($this->model->root() . '/article.txt'); | ||
|
||
$this->assertSame(['title' => 'Test'], $published); | ||
} | ||
|
||
public function testSave() | ||
{ | ||
Data::write($this->model->root() . '/article.txt', []); | ||
Data::write($this->model->root() . '/_changes/article.txt', []); | ||
|
||
$response = Changes::save($this->model, [ | ||
'title' => 'Test' | ||
]); | ||
|
||
$this->assertSame(['status' => 'ok'], $response); | ||
|
||
// the content file should be untouched | ||
$published = Data::read($this->model->root() . '/article.txt'); | ||
|
||
$this->assertSame([], $published); | ||
|
||
// the changes file should have the changes | ||
$changes = Data::read($this->model->root() . '/_changes/article.txt'); | ||
|
||
$this->assertSame(['title' => 'Test'], $changes); | ||
} | ||
|
||
public function testUnlock() | ||
{ | ||
} | ||
} |
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