This mini How-To will teach you how to run Akelos PHP Framework core tests on a windows environment using a XAMPP stack.
Supposing we have our XAMPP installed at “C:\xampp”, cURL enabled, a copy of Akelos at “C:\xampp\akelos_framework” and php.exe available at our current PATH.
We will create an Akelos application at “C:\xampp\htdocs\tests” for testing by running the command
php.exe C:\xampp\akelos_framework\akelos -d c:\xampp\htdocs\tests -f -deps
the '-deps' option will include the whole framework and its tests.
Now create a database named 'akelos_tests' and add a config file at config/config.php with the following settings (customize db credentials):
<?php
$database_settings = array(
'testing' => array(
'type' => 'mysql',
'database_file' => '',
'host' => 'localhost',
'port' => '',
'database_name' => 'akelos_tests',
'user' => 'root',
'password' => '',
'options' => ''
)
);
defined('AK_ENVIRONMENT') ? null : define('AK_ENVIRONMENT', 'testing');
define('AK_AVAILABLE_LOCALES', 'en,es');
define('AK_ACTIVE_RECORD_DEFAULT_LOCALES', 'en,es');
define('AK_APP_LOCALES', 'en,es');
define('AK_PUBLIC_LOCALES', 'en,es');
defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', 'C:\xampp\htdocs\tests');
defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', 'http://localhost/tests/test/fixtures/public');
// Update framework copy
exec('C:\xampp\php\php.exe C:\xampp\akelos_framework\akelos -d c:\xampp\htdocs\tests -f -deps');
// Fix testing htaccess
$_ht = file_get_contents('C:\xampp\htdocs\tests\test\fixtures\public\.htaccess');
$_ht = str_replace('# RewriteBase /test/fixtures/public','RewriteBase /tests/test/fixtures/public',$_ht);
file_put_contents('C:\xampp\htdocs\tests\test\fixtures\public\.htaccess',$_ht);
// Remove security rule
unlink('C:\xampp\htdocs\tests\test\.htaccess');
include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'boot.php');
?>
and now open a console, change to the testing dir
cd C:\xampp\htdocs\tests
and run the core unit tests with
php.exe script/test unit
If everything went OK you should see a “Unit tests for the Akelos Framework” message and in a few minutes you will see the results for the tests (hopefully)
C:\xampp\htdocs\tests>php.exe script/test unit Unit tests for the Akelos Framework OK Test cases run: 61/61, Passes: 2748, Failures: 0, Exceptions: 0
And that's it what it takes to run core tests.