1). From now on tests can be stored inside plugins under subfolder “tests”, for example:
“yf/plugins/my_plugin/tests/unit/my_plugin1.Test.php” – unit test
“yf/plugins/my_plugin/tests/acceptance/my_plugin.Cept.php” – codeception acceptance test
To run tests you should use scripts from folder: “yf/.dev/tests/bin/”
———–
Real examples from github repository:
https://github.com/yfix/yf/blob/master/.dev/tests/bin/codecept_run_all.sh
#!/bin/bash
(command -v codecept > /dev/null && cd ../ && codecept run)
https://github.com/yfix/yf/blob/master/.dev/tests/bin/codecept_run_all_separately.sh
#!/bin/bash
(
cd ../
for f in $(find ./acceptance -type f -name '*Cept.php'); do
echo $f;
codecept run acceptance $f;
done
for f in $(find ./functional -type f -name '*Cest.php'); do
echo $f;
codecept run functional $f;
done
for f in $(find ./unit -type f -name '*.Test.php'); do
echo $f;
codecept run unit $f;
done
https://github.com/yfix/yf/blob/master/.dev/tests/bin/phpunit_run_all.sh
#!/bin/bash
(command -v phpunit > /dev/null && cd ../ && phpunit -d memory_limit=1024M ./)
https://github.com/yfix/yf/blob/master/plugins/test/tests/unit/class_test_plugin.Test.php
<?php
!defined('YF_PATH') && define('YF_PATH', '/home/www/yf/');
require_once YF_PATH.'.dev/tests/yf_unit_tests_setup.php';
class class_test_plugin_test extends yf_unit_tests {
public function test1() {
$this->assertTrue(true);
}
}
https://github.com/yfix/yf/blob/master/plugins/test/tests/acceptance/html5fw_bs3_Cept.php
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('ensure that html5 bootstrap3 works');
$I->amOnPage('/test/html5fw_bs3');
$I->see('text');
———–
2). Also latest travis-ci yf setup consists of checking php files syntax based on utility “php-parallel-lint”.
Usually 1600 framework php sources are checked in 7-8 seconds!
https://github.com/yfix/yf/blob/master/.dev/tests/bin/php_parallel_lint_all.sh
#!/bin/bash
# composer global require jakub-onderka/php-parallel-lint
DIR=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd )
(
cd ../../../;
binary="parallel-lint"
if [[ -f "$TRAVIS_BUILD_DIR/vendor/bin/$binary" ]]; then
binary=$TRAVIS_BUILD_DIR"/vendor/bin/"$binary;
elif [[ -f "$DIR/vendor/bin/$binary" ]]; then
binary=$DIR"/vendor/bin/"$binary;
fi
$binary -e php --exclude libs --exclude vendor .
)
———–
3). Also, now YF core is fully compatible with upcoming PHP 7.0 branch, which is confirmed using unit tests, for example of travis-ci with nightly php build:
https://travis-ci.org/yfix/yf/jobs/88802913
Latest YF builds here:
https://travis-ci.org/yfix/yf
4). All YF unit tests now should inherit from class yf_unit_tests, currently stored here:
https://github.com/yfix/yf/blob/master/.dev/tests/yf_unit_tests_setup_shared.php
<?php
define('APP_PATH', __DIR__.'/_tmp/');
define('STORAGE_PATH', __DIR__.'/_tmp/');
$_SERVER['HTTP_HOST'] = 'test.dev';
if (!defined('YF_PATH')) {
$CONF['cache']['DRIVER'] = 'tmp';
$CONF['cache']['NO_CACHE'] = true;
define('YF_IN_UNIT_TESTS', true);
define('YF_PATH', dirname(dirname(__DIR__)).'/');
require YF_PATH.'classes/yf_main.class.php';
new yf_main($MAIN_TYPE ?: 'user', $no_db_connect = 1, $auto_init_all = 0, $CONF);
date_default_timezone_set('Europe/Kiev');
ini_set('display_errors', 'on');
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
}
abstract class yf_unit_tests extends PHPUnit_Framework_TestCase {
protected $backupGlobals = false;
protected $backupStaticAttributes = false;
protected $runTestInSeparateProcess = false;
protected $preserveGlobalState = false;
protected $inIsolation = false;
}