kenjis / ci-hmvc-ci-phpunit-test Goto Github PK
View Code? Open in Web Editor NEWCodeIgniter HMVC and ci-phpunit-test
CodeIgniter HMVC and ci-phpunit-test
After running below code
$ vendor/bin/phpunit -c application/tests/
I am getting below error
An uncaught Exception was encountered
Type: TypeError
Message: Argument 2 passed to PHPUnit_Framework_TestResult::addError() must be an instance of Exception, instance of Error given, called in /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/Framework/TestSuite.php on line 724
Filename: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/Framework/TestResult.php
Line Number: 195
Backtrace:
File: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/Framework/TestSuite.php
Line: 724
Function: addError
File: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/Framework/TestSuite.php
Line: 747
Function: run
File: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/TextUI/TestRunner.php
Line: 440
Function: run
File: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/TextUI/Command.php
Line: 149
Function: doRun
File: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/src/TextUI/Command.php
Line: 100
Function: run
File: /ci-hmvc-ci-phpunit-test/vendor/phpunit/phpunit/phpunit
Line: 47
Function: main
PHP Fatal error: Uncaught CIPHPUnitTestExitException: exit() called in exception_handler() function in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php:665
Stack trace:
0 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(665): exit_(1)
1 [internal function]: _exception_handler(Object(TypeError))
2 {main}
thrown in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php on line 665
Fatal error: Uncaught CIPHPUnitTestExitException: exit() called in exception_handler() function in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php:665
Stack trace:
0 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(665): exit_(1)
1 [internal function]: _exception_handler(Object(TypeError))
2 {main}
thrown in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php on line 665
A PHP Error was encountered
Severity: Error
Message: Uncaught CIPHPUnitTestExitException: exit() called in exception_handler() function in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php:665
Stack trace:
0 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(665): exit_(1)
1 [internal function]: _exception_handler(Object(TypeError))
2 {main}
thrown
Filename: /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php
Line Number: 665
Backtrace:
PHP Fatal error: Uncaught CIPHPUnitTestExitException: exit() called in error_handler() function in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php:635
Stack trace:
0 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(635): exit_(1)
1 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(692): _error_handler(1, 'Uncaught CIPHPU...', '/home/p...', 665)
2 [internal function]: _shutdown_handler()
3 {main}
thrown in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php on line 635
Fatal error: Uncaught CIPHPUnitTestExitException: exit() called in error_handler() function in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php:635
Stack trace:
0 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(635): exit_(1)
1 /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php(692): _error_handler(1, 'Uncaught CIPHPU...', '/home/p...', 665)
2 [internal function]: _shutdown_handler()
3 {main}
thrown in /ci-hmvc-ci-phpunit-test/vendor/codeigniter/framework/system/core/Common.php on line 635
Hi,
I have followed exact steps given in documentation but when I am running phpunit command then getting the following issue:
PHPUnit 5.5.0 by Sebastian Bergmann and contributors.
Database error: A Database Error Occurred
SQLSTATE[HY000] [14] unable to open database file
Filename: phar://D:/phpunit/phpunit.phar/phpunit/Framework/TestSuite.php
Line Number: 753
Though if I run
phpunit .
from tests folder then it is not throwing any error but there is not test case is running.
Please suggest the solution.
I follow this steps
$ git clone https://github.com/kenjis/ci-hmvc-ci-phpunit-test.git
$ cd ci-hmvc-ci-phpunit-test/
$ composer install
$ vendor/bin/phpunit -c application/tests/
but no test cases running. its give me this message
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Warning: The Xdebug extension is not loaded
No code coverage will be generated.
Hi,
I have the following problem or question,
How can I change the config file based on it's
$_SERVER['REQUEST_URI'] or $_SERVER['argv']?
I load the config file from the following site: application/testing/config.php
The modul hmvc changes, by the value the $_SERVER['REQUEST_URI'] or $_SERVER['argv'] get.
Example:
The reason why it changes is that in case of similar moduls the moduls do not update each other.
http://dev.local/gallery/--> Publik gallery list
http://dev.local/admin/gallery/ --> Admin gallery list
modules/admin/gallery/MVC directory
modules/admin/errors/MVC
modules/site/gallery/MVC directory
modules/site/errors/MVC
modules/webshop/errors/MVC directory
testing/config.php - module loading script:
/*
|--------------------------------------------------------------------------
| Modules locations
|--------------------------------------------------------------------------
|
| These are the folders where your modules are located. You may define an
| absolute path to the location or a relative path starting from the root
| directory.
|
*/
$modules_locations = array();
if (!isset($_SERVER['REMOTE_ADDR'])){ //CLI
//print_r($_SERVER['argv'][1]);
// exit;
if(isset($_SERVER['argv'])) {
switch (true) {
//case strstr($_SERVER['QUERY_STRING'], 'admin/'):
case strstr($_SERVER['argv'][1], 'admin/'):
$modules_locations[] = 'admin_modules';
//$modules_locations[] = 'other_modules';
if (!defined('APPLICATION')) define('APPLICATION', 'admin_website');
break;
//default module template public site
default:
$modules_locations[] = 'site_modules';
if (!defined('APPLICATION')) define('APPLICATION', 'public_website');
}
}
}else{
if(isset($_SERVER['REQUEST_URI'])) {
switch (true) {
//case strstr($_SERVER['QUERY_STRING'], 'admin/'):
case strstr($_SERVER['REQUEST_URI'], 'admin/'):
$modules_locations[] = 'admin_modules';
//$modules_locations[] = 'other_modules';
if (!defined('APPLICATION')) define('APPLICATION', 'admin_website');
break;
//default module template public site
default:
$modules_locations[] = 'site_modules';
if (!defined('APPLICATION')) define('APPLICATION', 'public_website');
}
}
}
$append_modules = array();
foreach($modules_locations as $modules){
$append_modules[APPPATH.'modules/'.($modules!=''?$modules.'/':'')] = '../modules/'.($modules!=''?$modules.'/':'');
}
$config['modules_locations'] = array(
//other modules
APPPATH.'modules/default_modules/' => '../modules/default_modules/',
//used website application modules
//APPPATH.'modules/'.($modules_locations!=''?$modules_locations.'/':'') => '../modules/'.($modules_locations!=''?$modules_locations.'/':''),
//APPPATH.'modules/site_modules/' => '../modules/site_modules/',
) + $append_modules;
I would load the routings belong to moduls, as moduls.
routes.php
$route['default_controller'] = 'Welcome';
$route['404_override'] = 'show_404';
$route['translate_uri_dashes'] = FALSE;
//print_r(config_item('modules_locations'));
//exit;
// Include routes every modules
$modules_locations = config_item('modules_locations') ? config_item('modules_locations') : FALSE;
if(!$modules_locations)
{
if(is_dir($modules_locations))
{
$modules_locations = array($modules_locations => '../modules/');
}
else
{
show_error('Modules directory not found');
}
}
foreach ($modules_locations as $key => $value)
{
if(is_dir($key)) {
if ($handle = opendir($key)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
if (is_dir($key . $entry)) {
$rfile = Modules::find('routes' . EXT, $entry, '/');
if ($rfile[0]) {
//echo $rfile[0].$rfile[1];
include($rfile[0] . $rfile[1]);
}
}
}
}
closedir($handle);
}
}else{
show_error('Modules directory not found');
}
}
Here is my problem:For some reason while the phpunit is running for the first time into the config file $_SERVER['argv'], it has been recognized˛/ percepted by the default controller and the default method.
(index.php/welcome/index)
The config.php is loaded twice by the phpunit but it runs like the HMVC moduls should only for the thrid time.
It will be loaded later with the settings it should operate with but by that time the hmvc (thirdpary library) has already been loaded and runs with wrong settings. Can I change the config settings based on what's like the request or the argv to operate in the phpunit?
Thanks for the answer.
I am trying to integrate phpunit-test on our project upon testing
this code return empty string on my end
$output = $this->request('GET','home/index');
here is my controller code
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends MY_Controller {
public $page_title = "Home";
private $promo;
function __construct() {
parent::__construct();
$this->load->helper('promos/promo');
$this->promo = $this->session->userdata('promo');
}
public function index() {
if (user_login()) {
$this->middle = 'public/home';
$this->public_layout();
} else {
$page_option = array('page_title' => $this->page_title, 'page' => 'home');
$this->data['page'] = $page_option;
page_init($page_option);
$this->middle = 'public/home';
$this->public_layout();
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.