mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-12-05 15:29:58 +01:00
Add Codeception testing suite
This commit is contained in:
@@ -105,3 +105,8 @@ If you have been following the [blog](http://getgrav.org/blog), [Twitter](https:
|
|||||||
The **standard free version**, is very powerful, and has more functionality than most commercial flat-file CMS systems.
|
The **standard free version**, is very powerful, and has more functionality than most commercial flat-file CMS systems.
|
||||||
|
|
||||||
We also intend to release in the near future a more feature-rich **pro version** that will include enhanced functionality, as well as some additional nice-to-have capabilities. This pro version will be a **paid** plugin the price of which is not yet 100% finalized.
|
We also intend to release in the near future a more feature-rich **pro version** that will include enhanced functionality, as well as some additional nice-to-have capabilities. This pro version will be a **paid** plugin the price of which is not yet 100% finalized.
|
||||||
|
|
||||||
|
# Running Tests
|
||||||
|
|
||||||
|
First install the dev dependencies by running `composer update` from the Grav root.
|
||||||
|
Then `composer test` will run the Unit Tests, which should be always executed successfully on any site.
|
||||||
|
|||||||
18
codeception.yml
Normal file
18
codeception.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
actor: Tester
|
||||||
|
paths:
|
||||||
|
tests: tests
|
||||||
|
log: tests/_output
|
||||||
|
data: tests/_data
|
||||||
|
support: tests/_support
|
||||||
|
envs: tests/_envs
|
||||||
|
settings:
|
||||||
|
bootstrap: _bootstrap.php
|
||||||
|
colors: true
|
||||||
|
memory_limit: 1024M
|
||||||
|
extensions:
|
||||||
|
enabled:
|
||||||
|
- Codeception\Extension\RunFailed
|
||||||
|
# - Codeception\Extension\Recorder
|
||||||
|
|
||||||
|
modules:
|
||||||
|
config:
|
||||||
@@ -2,5 +2,13 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"composer/semver": "^1.4",
|
"composer/semver": "^1.4",
|
||||||
"fguillot/picofeed": "@stable"
|
"fguillot/picofeed": "@stable"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"codeception/codeception": "^2.1",
|
||||||
|
"fzaninotto/faker": "^1.5"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "vendor/bin/codecept run unit",
|
||||||
|
"test-windows": "vendor\\bin\\codecept run unit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
tests/_bootstrap.php
Normal file
11
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
tests/_support/Helper/Unit.php
Normal file
80
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
tests/_support/UnitTester.php
Normal file
26
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
tests/unit.suite.yml
Normal file
9
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
tests/unit/_bootstrap.php
Normal file
3
tests/unit/_bootstrap.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
// Here you can initialize variables that will be available to your tests
|
||||||
|
|
||||||
Reference in New Issue
Block a user