mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
phpunit test cases runnable; WIP teaching phpunit what a codeigniter3 is
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// Set environment
|
||||
define('ENVIRONMENT', 'testing');
|
||||
$_SERVER['CI_ENV'] = 'testing';
|
||||
|
||||
// Setup CI core constants
|
||||
$system_path = __DIR__ . '/vendor/codeigniter/framework/system';
|
||||
$application_folder = __DIR__ . '/application';
|
||||
$view_folder = $application_folder . '/views';
|
||||
|
||||
if (!defined('ICONV_ENABLED')) define('ICONV_ENABLED', function_exists('iconv'));
|
||||
if (!defined('MB_ENABLED')) define('MB_ENABLED', extension_loaded('mbstring'));
|
||||
|
||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
define('BASEPATH', rtrim(realpath($system_path), '/') . '/');
|
||||
define('APPPATH', rtrim(realpath($application_folder), '/') . '/');
|
||||
define('VIEWPATH', rtrim(realpath($view_folder), '/') . '/');
|
||||
|
||||
// Autoload Composer and project config
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
require_once __DIR__ . '/config/global.config.inc.php';
|
||||
require_once __DIR__ . '/config/vilesci.config.inc.php';
|
||||
require_once __DIR__ . '/application/config/core_includes.php';
|
||||
|
||||
// Load base CI functionality manually, without routing
|
||||
require_once BASEPATH . 'core/Common.php';
|
||||
|
||||
$CFG =& load_class('Config', 'core');
|
||||
$UNI =& load_class('Utf8', 'core');
|
||||
$URI =& load_class('URI', 'core');
|
||||
$RTR =& load_class('Router', 'core'); // Optional: Don't route
|
||||
$OUT =& load_class('Output', 'core');
|
||||
|
||||
require_once BASEPATH . 'core/Controller.php';
|
||||
|
||||
//require_once BASEPATH . 'core/CodeIgniter.php';
|
||||
function &get_instance() { return CI_Controller::get_instance(); }
|
||||
|
||||
// Manually load your custom controller later in tests
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<phpunit bootstrap="index.ci.php">
|
||||
<phpunit bootstrap="index.phpunit.php">
|
||||
<testsuites>
|
||||
<testsuite name="UnitTests">
|
||||
<directory>system/UnitTests/vertragsbestandteil/gui</directory>
|
||||
<testsuite name="BookmarkTest">
|
||||
<directory>system/UnitTests/api/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace BookmarkTest;
|
||||
echo "BookmarkTest loaded\n";
|
||||
|
||||
|
||||
echo "Resolved path: " . APPPATH.'controllers/api/frontend/v1/Bookmark.php' . "\n";
|
||||
|
||||
|
||||
//require_once(APPPATH.'controllers/api/frontend/v1/Bookmark.php');
|
||||
//require_once(APPPATH.'libraries/AuthLib.php');
|
||||
|
||||
use Bookmark;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookmarkTest extends TestCase
|
||||
{
|
||||
private $_ci;
|
||||
|
||||
// public function setUp(): void
|
||||
// {
|
||||
// error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
|
||||
//
|
||||
// echo 'in the setUp';
|
||||
// // Load CodeIgniter instance
|
||||
// $this->_ci = &get_instance();
|
||||
//
|
||||
// if (!is_object($this->_ci)) {
|
||||
// throw new \Exception('CI instance is not available');
|
||||
// }
|
||||
//
|
||||
// $this->_ci->load->library('AuthLib', null, 'AuthLib');
|
||||
//
|
||||
// $this->_ci->AuthLib->loginLDAP('horauer', 'FHCompleteDemo42!');
|
||||
// $this->_ci->load->controller('api/v1/Bookmark');
|
||||
//
|
||||
// $this->obj = new Bookmark();
|
||||
// }
|
||||
|
||||
/** @test */
|
||||
public function test_true()
|
||||
{
|
||||
echo 'in the test_true case';
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user