Merge pull request #1 from Karaka-Management/develop

Merge
This commit is contained in:
Dennis Eichhorn 2023-09-30 02:02:05 +02:00 committed by GitHub
commit d58248e5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 6160 additions and 0 deletions

35
.github/dev_bug_report.md vendored Normal file
View File

@ -0,0 +1,35 @@
---
name: Dev Bug Report
about: Create a report to help us improve
title: ''
labels: stat_backlog, type_bug
assignees: ''
---
# Bug Description
A clear and concise description of what the bug is.
# How to Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Minimal Code Example
```
// your code ...
```
# Expected Behavior
A clear and concise description of what you expected to happen.
# Screenshots
If applicable, add screenshots to help explain your problem.
# Additional Information
Add any other context about the problem here.

18
.github/dev_feature_request.md vendored Normal file
View File

@ -0,0 +1,18 @@
---
name: Dev Feature Request
about: Suggest an idea for this project
title: ''
labels: stat_backlog, type_feature
assignees: ''
---
# What is the feature you request
* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
* A clear and concise description of what you want to happen.
# Alternatives
A clear and concise description of any alternative solutions or features you've considered.
# Additional Information
Add any other context or screenshots about the feature request here.

40
.github/user_bug_report.md vendored Normal file
View File

@ -0,0 +1,40 @@
---
name: User Bug Report
about: Create a report to help us improve
title: ''
labels: stat_backlog, type_bug
assignees: ''
---
# Bug Description
A clear and concise description of what the bug is.
# How to Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
# Expected Behavior
A clear and concise description of what you expected to happen.
# Screenshots
If applicable, add screenshots to help explain your problem.
# System Information
- System: [e.g. PC or iPhone11, ...]
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- KarakaVersion [e.g. 22]
# Additional Information
Add any other context about the problem here.

21
.github/user_feature_request.md vendored Normal file
View File

@ -0,0 +1,21 @@
---
name: User Feature Request
about: Suggest an idea for this project
title: ''
labels: stat_backlog, type_feature
assignees: ''
---
# What is the feature you request
* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
* A clear and concise description of what you want to happen.
# Alternatives
A clear and concise description of any alternative solutions or features you've considered.
# Additional Information
Add any other context or screenshots about the feature request here.

13
.github/workflows/greetings.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Greetings
on: [pull_request, issues]
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Thank you for createing this issue. We will check it as soon as possible.'
pr-message: 'Thank you for your pull request. We will check it as soon as possible.'

10
.github/workflows/image.yml vendored Normal file
View File

@ -0,0 +1,10 @@
name: Image optimization
on: [push, pull_request]
jobs:
general_image_workflow:
uses: Karaka-Management/Karaka/.github/workflows/image.yml@develop
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAT: ${{ secrets.GH_PAT }}

20
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: CI
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
schedule:
- cron: '0 0 1,15 * *'
jobs:
general_module_workflow:
uses: Karaka-Management/Karaka/.github/workflows/php_template.yml@develop
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAT: ${{ secrets.GH_PAT }}

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
Build
*.cache
.directory
Vagrantfile
vendor
bower_components
node_modules
*.log
.vagrant
.vscode
.sass-cache
cache
Cache
Libraries
.idea

View File

@ -0,0 +1,33 @@
[
{
"id": 1008601001,
"pid": "/",
"type": 2,
"subtype": 1,
"name": "QualityControl",
"uri": "{/base}/qualitymanagement/qualitycontrol/list",
"target": "self",
"icon": null,
"order": 65,
"from": "QualityControl",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008501001,
"children": [
{
"id": 1008602001,
"pid": "/qualitymanagement/qualitycontrol",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/base}/qualitymanagement/qualitycontrol/list",
"target": "self",
"icon": null,
"order": 1,
"from": "QualityControl",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008601001,
"children": []
}
]
}
]

View File

@ -0,0 +1,43 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Navigation class.
*
* @package Modules\QualityControl\Admin\Install
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Navigation
{
/**
* Install navigation providing
*
* @param ApplicationAbstract $app Application
* @param string $path Module path
*
* @return void
*
* @since 1.0.0
*/
public static function install(ApplicationAbstract $app, string $path) : void
{
\Modules\Navigation\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Navigation.install.json']);
}
}

36
Admin/Installer.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Admin;
use phpOMS\Module\InstallerAbstract;
/**
* Installer class.
*
* @package Modules\QualityControl\Admin
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class Installer extends InstallerAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

View File

@ -0,0 +1,3 @@
<?php declare(strict_types=1);
return [];

36
Admin/Status.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Admin;
use phpOMS\Module\StatusAbstract;
/**
* Status class.
*
* @package Modules\QualityControl\Admin
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class Status extends StatusAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

36
Admin/Uninstaller.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Admin;
use phpOMS\Module\UninstallerAbstract;
/**
* Uninstaller class.
*
* @package Modules\QualityControl\Admin
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class Uninstaller extends UninstallerAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

36
Admin/Updater.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Admin;
use phpOMS\Module\UpdaterAbstract;
/**
* Updater class.
*
* @package Modules\QualityControl\Admin
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class Updater extends UpdaterAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

View File

@ -0,0 +1,27 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Controller;
/**
* QualityControl controller class.
*
* @package Modules\QualityControl
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class BackendController extends Controller
{
}

77
Controller/Controller.php Normal file
View File

@ -0,0 +1,77 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\QualityControl
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\QualityControl\Controller;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
/**
* QualityControl controller class.
*
* @package Modules\QualityControl
* @license OMS License 2.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Controller extends ModuleAbstract implements WebInterface
{
/**
* Module path.
*
* @var string
* @since 1.0.0
*/
public const MODULE_PATH = __DIR__ . '/../';
/**
* Module version.
*
* @var string
* @since 1.0.0
*/
public const MODULE_VERSION = '1.0.0';
/**
* Module name.
*
* @var string
* @since 1.0.0
*/
public const MODULE_NAME = 'QualityControl';
/**
* Module id.
*
* @var int
* @since 1.0.0
*/
public const MODULE_ID = 1008600000;
/**
* Providing.
*
* @var string[]
* @since 1.0.0
*/
public static array $providing = [];
/**
* Dependencies.
*
* @var string[]
* @since 1.0.0
*/
public static array $dependencies = [];
}

49
ICAL.txt Executable file
View File

@ -0,0 +1,49 @@
# Individual Contributor License Agreement ("CLA") 1.0
Thank you for your interest in Karaka-Management (the "Company"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Company must provide a Contributor License Agreement ("CLA") on file that has been made available to each Contributor. This license is for your protection as a Contributor as well as the protection of the Company and its users; it does not change your rights to use your own Contributions for any other purpose.
By contributing to the Company You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Company. In return, the Company shall not use Your Contributions in a way that is contrary to the public benefit or inconsistent with its bylaws in effect at the time of the Contribution. Except for the license granted herein to the Company and recipients of software distributed by the Company, You reserve all right, title, and interest in and to Your Contributions.
## Definitions
**"You" (or "Your")**
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with the Company. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
**"Contribution"**
"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Company for inclusion in, or documentation of, any of the products owned or managed by the Company (the "Work"). This includes but is not limited to technical material, techniques, articles, sketches, drawings, images, models, inventions, know-how, processes, apparatus, equipment, algorithms, software programs, software source documents, and formula related to the current, future and proposed products and services regarding the Company". For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Company or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Company for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
## Grant of Copyright License
Subject to the terms and conditions of this Agreement, You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sub license, and distribute Your Contributions and such derivative works.
## Grant of Patent License
Subject to the terms and conditions of this Agreement, You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
## Authorization
You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Company, or that your employer has executed a separate Corporate CLA with the Company.
You represent that each of Your Contributions is Your original creation (see "Third-party Contribution" for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
## Support
You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
## Third-party Contribution
Should You wish to submit work that is not Your original creation, You may submit it to the Company separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
## Survival
This Agreement shall govern all communications between the parties. You understand that this Agreement stays active even if the connection with You gets terminated unless the project the Company gets officially canceled by the project manager "Dennis Eichhorn".
## Governing Law and Jurisdiction
This Agreement shall be governed exclusively by German law. The courts of Hessen, Germany shall have exclusive jurisdiction.
## Entire Agreement
This agreement constitutes the entire agreement and supersedes all prior or contemporaneous oral or written agreements concerning such Contribution. This agreement may only be changed by mutual agreement of authorized representatives of the parties in writing. You agree to notify the Company of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.

0
README.md Normal file → Executable file
View File

23
composer.json Executable file
View File

@ -0,0 +1,23 @@
{
"name": "karaka/module",
"description": "Module for Jingga.",
"authors": [
{
"name": "Dennis Eichhorn",
"email": "spl1nes.com@googlemail.com"
}
],
"require-dev": {
"phpunit/phpunit": ">=9.4",
"friendsofphp/php-cs-fixer": ">=3.8",
"squizlabs/php_codesniffer": ">=3.6",
"phpmd/phpmd": ">=2.9",
"phpstan/phpstan": ">=1.8.6",
"phan/phan": ">=3.2.6",
"phploc/phploc": ">=7.0",
"phpmetrics/phpmetrics": ">=2.8",
"rector/rector": ">=0.18.0"
},
"minimum-stability": "dev",
"prefer-stable": true
}

4856
composer.lock generated Executable file

File diff suppressed because it is too large Load Diff

47
info.json Normal file
View File

@ -0,0 +1,47 @@
{
"name": {
"id": 1008600000,
"internal": "QualityControl",
"external": "QualityControl"
},
"category": "Tools",
"version": "1.0.0",
"requirements": {
"phpOMS": "1.0.0",
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Jingga",
"website": "jingga.app"
},
"description": "The administration module.",
"directory": "QualityControl",
"dependencies": {
"Admin": "1.0.0",
"Tasks": "1.0.0",
"Tools": "1.0.0"
},
"providing": {
"Navigation": "*"
},
"load": [
{
"pid": [
"/qualitymanagement/qualitycontrol"
],
"type": 4,
"for": "Content",
"file": "QualityControl",
"from": "QualityControl"
},
{
"pid": [
"/"
],
"type": 5,
"from": "QualityControl",
"for": "Navigation",
"file": "Navigation"
}
]
}

27
tests/Admin/AdminTest.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\QualityControl\tests\Admin;
/**
* @internal
*/
final class AdminTest extends \PHPUnit\Framework\TestCase
{
protected const NAME = 'QualityControl';
protected const URI_LOAD = 'http://127.0.0.1/en/backend/qualitymanagement/qualitycontrol';
use \tests\Modules\ModuleTestTrait;
}

111
tests/Autoloader.php Normal file
View File

@ -0,0 +1,111 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules/tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\QualityControl\tests;
\spl_autoload_register('\Modules\QualityControl\tests\Autoloader::defaultAutoloader');
/**
* Autoloader class.
*
* @package tests
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Autoloader
{
/**
* Base paths for autoloading
*
* @var string[]
* @since 1.0.0
*/
private static $paths = [
__DIR__ . '/../',
__DIR__ . '/../MainRepository/',
__DIR__ . '/../../',
];
/**
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
}
/**
* Add base path for autoloading
*
* @param string $path Absolute base path with / at the end
*
* @return void
*
* @since 1.0.0
*/
public static function addPath(string $path) : void
{
self::$paths[] = \rtrim($path, '/\\') . '/';
}
/**
* Loading classes by namespace + class name.
*
* @param string $class Class path
*
* @example Autoloader::defaultAutoloader('\phpOMS\Autoloader') // void
*
* @return void
*
* @since 1.0.0
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'Karaka/Web/', $class);
}
$class2 = $class;
$class3 = $class;
$pos = \stripos($class, '/');
if ($pos !== false) {
$class3 = \substr($class, $pos + 1);
$pos = \stripos($class, '/', $pos + 1);
if ($pos !== false) {
$class2 = \substr($class, $pos + 1);
}
}
foreach (self::$paths as $path) {
if (($file = \realpath($path . $class2 . '.php')) !== false && \stripos($file, $class3) !== false) {
include_once $file;
return;
} elseif (\is_file($file = $path . $class . '.php')) {
include_once $file;
return;
}
}
}
}

490
tests/Bootstrap.php Normal file
View File

@ -0,0 +1,490 @@
<?php
declare(strict_types=1);
\ini_set('memory_limit', '2048M');
\ini_set('display_errors', '1');
\ini_set('display_startup_errors', '1');
\error_reporting(\E_ALL);
\setlocale(\LC_ALL, 'en_US.UTF-8');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/Autoloader.php';
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Log\FileLogger;
$IS_GITHUB = false;
$temp = \array_keys($_SERVER);
foreach ($temp as $key) {
if (\is_string($key) && \stripos(\strtolower($key), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
if (!$IS_GITHUB) {
foreach ($_SERVER as $value) {
if (\is_string($value) && \stripos(\strtolower($value), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
}
$temp = \array_keys(\getenv());
if (!$IS_GITHUB) {
foreach ($temp as $key) {
if (\is_string($key) && \stripos(\strtolower($key), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
}
$temp = \array_values(\getenv());
if (!$IS_GITHUB) {
foreach ($temp as $value) {
if (\is_string($value) && \stripos(\strtolower($value), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
}
$GLOBALS['is_github'] = $IS_GITHUB;
// Initialize file logger with correct path
$tmp = FileLogger::getInstance(__DIR__ . '/../Logs');
$CONFIG = [
'db' => [
'core' => [
'masters' => [
'admin' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
'postgresql' => [
'admin' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
'sqlite' => [
'admin' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
'mssql' => [
'admin' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
],
],
'cache' => [
'redis' => [
'db' => 1,
'host' => '127.0.0.1',
'port' => 6379,
],
'memcached' => [
'host' => '127.0.0.1',
'port' => 11211,
],
],
'mail' => [
'imap' => [
'host' => '127.0.0.1',
'port' => 143,
'ssl' => false,
'user' => 'test',
'password' => '123456',
],
'pop3' => [
'host' => '127.0.0.1',
'port' => 25,
'ssl' => false,
'user' => 'test',
'password' => '123456',
],
],
'log' => [
'file' => [
'path' => __DIR__ . '/Logs',
],
],
'page' => [
'root' => '/',
'https' => false,
],
'app' => [
'path' => __DIR__,
'default' => [
'app' => 'Backend',
'id' => 'backend',
'lang' => 'en',
'theme' => 'Backend',
'org' => 1,
],
'domains' => [
'127.0.0.1' => [
'app' => 'Backend',
'id' => 'backend',
'lang' => 'en',
'theme' => 'Backend',
'org' => 1,
],
],
],
'socket' => [
'master' => [
'host' => '127.0.0.1',
'limit' => 300,
'port' => 4310,
],
],
'language' => [
'en',
],
'apis' => [
],
];
// Reset database
if (\defined('RESET') && RESET === '1') {
if (\extension_loaded('pdo_mysql')) {
try {
$db = new \PDO('mysql:host=' .
$CONFIG['db']['core']['masters']['admin']['host'],
$CONFIG['db']['core']['masters']['admin']['login'],
$CONFIG['db']['core']['masters']['admin']['password']
);
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db = null;
} catch (\Throwable $_) {
echo "\nCouldn't connect to MYSQL DB\n";
}
}
if (\extension_loaded('pdo_pgsql')) {
try {
$db = new \PDO('pgsql:host=' .
$CONFIG['db']['core']['postgresql']['admin']['host'],
$CONFIG['db']['core']['postgresql']['admin']['login'],
$CONFIG['db']['core']['postgresql']['admin']['password']
);
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db = null;
} catch (\Throwable $_) {
echo "\nCouldn't connect to POSTGRESQL DB\n";
}
}
if (\extension_loaded('pdo_sqlsrv')) {
try {
$db = new \PDO('sqlsrv:Server=' .
$CONFIG['db']['core']['mssql']['admin']['host'],
$CONFIG['db']['core']['mssql']['admin']['login'],
$CONFIG['db']['core']['mssql']['admin']['password']
);
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db = null;
} catch (\Throwable $_) {
echo "\nCouldn't connect to MSSQL DB\n";
}
}
}
$httpSession = new HttpSession();
$GLOBALS['session'] = $httpSession;
$GLOBALS['dbpool'] = new DatabasePool();
$GLOBALS['dbpool']->create('admin', $CONFIG['db']['core']['masters']['admin']);
$GLOBALS['dbpool']->create('select', $CONFIG['db']['core']['masters']['select']);
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
$GLOBALS['dbpool']->create('update', $CONFIG['db']['core']['masters']['update']);
$GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete']);
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
DataMapperFactory::db($GLOBALS['dbpool']->get());
$GLOBALS['frameworkpath'] = '/phpOMS/';
function phpServe() : void
{
// OS detection
$isWindows = \stristr(\php_uname('s'), 'Windows') !== false;
// Command that starts the built-in web server
if ($isWindows) {
$command = \sprintf(
'wmic process call create "php -S %s:%d -t %s" | find "ProcessId"',
WEB_SERVER_HOST,
WEB_SERVER_PORT,
__DIR__ . '/../' . WEB_SERVER_DOCROOT
);
$killCommand = 'taskkill /f /pid ';
} else {
$command = \sprintf(
'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!',
WEB_SERVER_HOST,
WEB_SERVER_PORT,
WEB_SERVER_DOCROOT
);
$killCommand = 'kill ';
}
// Execute the command and store the process ID
$output = [];
echo 'Starting server...' . \PHP_EOL;
echo \sprintf(' Current directory: %s', \getcwd()) . \PHP_EOL;
echo \sprintf(' %s', $command);
\exec($command, $output);
// Get PID
if ($isWindows) {
$pid = \explode('=', $output[0]);
$pid = \str_replace(' ', '', $pid[1]);
$pid = \str_replace(';', '', $pid);
} else {
$pid = (int) $output[0];
}
// Log
echo \sprintf(
' %s - Web server started on %s:%d with PID %d',
\date('r'),
WEB_SERVER_HOST,
WEB_SERVER_PORT,
$pid
) . \PHP_EOL;
// Kill the web server when the process ends
\register_shutdown_function(function() use ($killCommand, $pid) : void {
echo \PHP_EOL . 'Stopping server...' . \PHP_EOL;
echo \sprintf(' %s - Killing process with ID %d', \date('r'), $pid) . \PHP_EOL;
\exec($killCommand . $pid);
});
}
try {
\phpServe();
} catch(\Throwable $t) {
echo $t->getMessage();
}

58
tests/phpunit_default.xml Normal file
View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
<include>
<directory suffix=".php">../</directory>
</include>
<exclude>
<directory>../vendor*</directory>
<directory>../MainRepository*</directory>
<directory>../Admin/Install/Application*</directory>
<directory>../phpOMS*</directory>
<directory>../tests*</directory>
<directory>../*/tests*</directory>
<directory>../**/tests*</directory>
<directory>*/tests*</directory>
<directory suffix="tpl.php">../*</directory>
<directory suffix="lang.php">../*</directory>
<directory suffix="Test.php">../*</directory>
<directory suffix="Routes.php">../*</directory>
<directory suffix="Hooks.php">../*</directory>
<directory>../**/test*</directory>
<directory>../**/Theme*</directory>
<directory>../**/Admin/Routes*</directory>
<directory>../**/Admin/Hooks*</directory>
<directory>../**/Admin/Install*</directory>
<directory>../Media/Files*</directory>
</exclude>
<report>
<clover outputFile="coverage.xml"/>
<html outputDirectory="../tests" lowUpperBound="75" highLowerBound="95"/>
</report>
</coverage>
<testsuites>
<testsuite name="Install">
<directory>../MainRepository/Install/tests*</directory>
</testsuite>
<testsuite name="Module">
<directory>../tests*</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>volume</group>
<group>maybe</group>
</exclude>
</groups>
<logging>
<junit outputFile="../tests/junit_php.xml"/>
<testdoxHtml outputFile="../tests/index.html"/>
<testdoxText outputFile="../tests/testdox.txt"/>
</logging>
<php>
<const name="WEB_SERVER_HOST" value="localhost"/>
<const name="WEB_SERVER_PORT" value="1234"/>
<const name="WEB_SERVER_DOCROOT" value="./Karaka"/>
<const name="RESET" value="1"/>
</php>
</phpunit>