-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from Frankva/unit_tests
Unit tests
- Loading branch information
Showing
65 changed files
with
4,253 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: CodeIgniter | ||
|
||
on: | ||
push: | ||
# branches: [ "master" ] | ||
pull_request: | ||
# branches: [ "master" ] | ||
release: | ||
types: [published] | ||
workflow_dispatch: # to run manually | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
codeigniter-test: | ||
environment: unit_test | ||
runs-on: ubuntu-latest | ||
services: | ||
db: | ||
image: mariadb | ||
env: | ||
MYSQL_DATABASE: ci4_test | ||
MYSQL_ROOT_PASSWORD: root | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" | ||
# Docs: https://getcomposer.org/doc/articles/scripts.md | ||
|
||
|
||
- name: Execute tests (Unit and Feature tests) via PHPUnit | ||
env: | ||
database.tests.hostname: 127.0.0.1 | ||
database.tests.database: ci4_test | ||
database.tests.username: root | ||
database.tests.password: root | ||
database.tests.DBDriver: MySQLi | ||
database.tests.port: 3306 | ||
database.tests.DBPrefix: | ||
CLIENT_ID: ${{ secrets.CLIENT_ID }} | ||
TENANT_ID: ${{ secrets.TENANT_ID }} | ||
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} | ||
GRAPH_USER_SCOPES: ${{ secrets.GRAPH_USER_SCOPES }} | ||
REDIRECT_URI: ${{ secrets.REDIRECT_URI }} | ||
run: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title><?= lang('user_lang.code_error_403') ?></title> | ||
|
||
<style> | ||
div.logo { | ||
height: 200px; | ||
width: 155px; | ||
display: inline-block; | ||
opacity: 0.08; | ||
position: absolute; | ||
top: 2rem; | ||
left: 50%; | ||
margin-left: -73px; | ||
} | ||
body { | ||
height: 100%; | ||
background: #fafafa; | ||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
color: #777; | ||
font-weight: 300; | ||
} | ||
h1 { | ||
font-weight: lighter; | ||
letter-spacing: normal; | ||
font-size: 3rem; | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
color: #222; | ||
} | ||
.wrap { | ||
max-width: 1024px; | ||
margin: 5rem auto; | ||
padding: 2rem; | ||
background: #fff; | ||
text-align: center; | ||
border: 1px solid #efefef; | ||
border-radius: 0.5rem; | ||
position: relative; | ||
} | ||
pre { | ||
white-space: normal; | ||
margin-top: 1.5rem; | ||
} | ||
code { | ||
background: #fafafa; | ||
border: 1px solid #efefef; | ||
padding: 0.5rem 1rem; | ||
border-radius: 5px; | ||
display: block; | ||
} | ||
p { | ||
margin-top: 1.5rem; | ||
} | ||
.footer { | ||
margin-top: 2rem; | ||
border-top: 1px solid #efefef; | ||
padding: 1em 2em 0 2em; | ||
font-size: 85%; | ||
color: #999; | ||
} | ||
a:active, | ||
a:link, | ||
a:visited { | ||
color: #dd4814; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="wrap"> | ||
<h1><?= lang('user_lang.code_error_403')?></h1> | ||
|
||
<p> | ||
<?php if (ENVIRONMENT !== 'production') : ?> | ||
<?= nl2br(esc($message)) ?> | ||
<?php else : ?> | ||
<?= nl2br(esc($message)) ?> | ||
<?php endif ?> | ||
</p> | ||
</div> | ||
<?php if (ENVIRONMENT !== 'production') : ?> | ||
<?= d($exception->getTrace()) ?> | ||
<?php endif ?> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Common\Exceptions; | ||
|
||
use CodeIgniter\Exceptions\HTTPExceptionInterface; | ||
use CodeIgniter\Exceptions\DebugTraceableTrait; | ||
use CodeIgniter\Exceptions\ExceptionInterface; | ||
use RuntimeException; | ||
|
||
class AccessDeniedException extends RuntimeException implements | ||
ExceptionInterface, HTTPExceptionInterface | ||
{ | ||
use DebugTraceableTrait; | ||
|
||
/** | ||
* HTTP status code | ||
* | ||
* @var int | ||
*/ | ||
protected $code = 403; | ||
|
||
public static function forPageAccessDenied(?string $message = null) | ||
{ | ||
return new static($message | ||
?? lang('user_lang.msg_err_access_denied_message')); | ||
} | ||
} |
Oops, something went wrong.