init
This commit is contained in:
11
user/plugins/admin/tests/_bootstrap.php
Normal file
11
user/plugins/admin/tests/_bootstrap.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// This is global bootstrap for autoloading
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Faker\Factory;
|
||||
|
||||
ini_set('error_log', __DIR__ . '/error.log');
|
||||
|
||||
$fake = Factory::create();
|
||||
Fixtures::add('fake', $fake);
|
||||
|
||||
80
user/plugins/admin/tests/_support/Helper/Unit.php
Normal file
80
user/plugins/admin/tests/_support/Helper/Unit.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
use Codeception;
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
/**
|
||||
* Class Unit
|
||||
* @package Helper
|
||||
*/
|
||||
class Unit extends Codeception\Module
|
||||
{
|
||||
/**
|
||||
* HOOK: used after configuration is loaded
|
||||
*/
|
||||
public function _initialize() {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: on every Actor class initialization
|
||||
*/
|
||||
public function _cleanup() {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: before suite
|
||||
*
|
||||
* @param array $settings
|
||||
*/
|
||||
public function _beforeSuite($settings = []) {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: after suite
|
||||
**/
|
||||
public function _afterSuite() {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: before each step
|
||||
*
|
||||
* @param Codeception\Step $step*
|
||||
*/
|
||||
public function _beforeStep(Codeception\Step $step) {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: after each step
|
||||
*
|
||||
* @param Codeception\Step $step
|
||||
*/
|
||||
public function _afterStep(Codeception\Step $step) {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: before each suite
|
||||
*
|
||||
* @param Codeception\TestCase $test
|
||||
*/
|
||||
public function _before(Codeception\TestCase $test) {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: before each suite
|
||||
*
|
||||
* @param Codeception\TestCase $test
|
||||
*/
|
||||
public function _after(Codeception\TestCase $test) {
|
||||
}
|
||||
|
||||
/**
|
||||
* HOOK: on fail
|
||||
*
|
||||
* @param Codeception\TestCase $test
|
||||
* @param $fail
|
||||
*/
|
||||
public function _failed(Codeception\TestCase $test, $fail) {
|
||||
}
|
||||
}
|
||||
26
user/plugins/admin/tests/_support/UnitTester.php
Normal file
26
user/plugins/admin/tests/_support/UnitTester.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
9
user/plugins/admin/tests/unit.suite.yml
Normal file
9
user/plugins/admin/tests/unit.suite.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
# Codeception Test Suite Configuration
|
||||
#
|
||||
# Suite for unit (internal) tests.
|
||||
|
||||
class_name: UnitTester
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
- \Helper\Unit
|
||||
3
user/plugins/admin/tests/unit/_bootstrap.php
Normal file
3
user/plugins/admin/tests/unit/_bootstrap.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
|
||||
42
user/plugins/admin/tests/unit/classes/controllerTest.php
Normal file
42
user/plugins/admin/tests/unit/classes/controllerTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Grav\Plugin;
|
||||
|
||||
/**
|
||||
* Class ControllerTest
|
||||
*/
|
||||
class ControllerTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
protected $controller;
|
||||
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
require_once(__DIR__ . '/../../../classes/adminbasecontroller.php');
|
||||
require_once(__DIR__ . '/../../../classes/admincontroller.php');
|
||||
$this->controller = new \Grav\Plugin\Admin\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