mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-30 01:36:27 +01:00
Fix #821 issue in saving a page to a new language when the filename does not contain the filename yet.
Also extract determineFilenameIncludingLanguage() method and add corresponding test.
This commit is contained in:
41
tests/unit/classes/controllerTest.php
Normal file
41
tests/unit/classes/controllerTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Grav\Plugin;
|
||||
|
||||
/**
|
||||
* Class ControllerTest
|
||||
*/
|
||||
class ControllerTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
protected $controller;
|
||||
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
require_once(__DIR__ . '/../../../classes/controller.php');
|
||||
$this->controller = new AdminController();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testDetermineFilenameIncludingLanguage()
|
||||
{
|
||||
$language = 'en-GB';
|
||||
|
||||
$this->assertSame('testing.en-GB.md', $this->controller->determineFilenameIncludingLanguage('testing.md', $language));
|
||||
$this->assertSame('testing.en-GB.md', $this->controller->determineFilenameIncludingLanguage('testing.en.md', $language));
|
||||
$this->assertSame('testing.en-GB.md', $this->controller->determineFilenameIncludingLanguage('testing.it.md', $language));
|
||||
$this->assertSame('testing.en-GB.md', $this->controller->determineFilenameIncludingLanguage('testing.en-GB.md', $language));
|
||||
|
||||
$language = 'it';
|
||||
|
||||
$this->assertSame('testing.it.md', $this->controller->determineFilenameIncludingLanguage('testing.md', $language));
|
||||
$this->assertSame('testing.it.md', $this->controller->determineFilenameIncludingLanguage('testing.en.md', $language));
|
||||
$this->assertSame('testing.it.md', $this->controller->determineFilenameIncludingLanguage('testing.it.md', $language));
|
||||
$this->assertSame('testing.it.md', $this->controller->determineFilenameIncludingLanguage('testing.en-GB.md', $language));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user