Skip to content

Commit f76daf5

Browse files
authored
Merge pull request #4 from SDPM-lab/test_case
Add test case
2 parents c432559 + a747f0e commit f76daf5

94 files changed

Lines changed: 5862 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-phpunit.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: PHPUnit
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
paths:
8+
- 'src/**'
9+
- 'test/**'
10+
- composer.json
11+
- '**.php'
12+
- .github/workflows/test-phpunit.yml
13+
pull_request:
14+
branches:
15+
- dev
16+
paths:
17+
- 'src/**'
18+
- 'test/**'
19+
- composer.json
20+
- '**.php'
21+
- .github/workflows/test-phpunit.yml
22+
23+
jobs:
24+
25+
tests:
26+
runs-on: ubuntu-18.04
27+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
28+
name: PHP ${{ matrix.php-ver }}
29+
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
php-ver: ['7.3','7.4']
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
39+
- name: Setup PHP, with composer and extensions
40+
run: |
41+
sudo add-apt-repository ppa:ondrej/php -y
42+
sudo apt update -y
43+
sudo apt-get install php${{ matrix.php-ver }}
44+
sudo apt install php-pear php${{ matrix.php-ver }}-curl php${{ matrix.php-ver }}-dev php${{ matrix.php-ver }}-mbstring php${{ matrix.php-ver }}-zip php${{ matrix.php-ver }}-mysql php${{ matrix.php-ver }}-xml php${{ matrix.php-ver }}-fpm php${{ matrix.php-ver }}-intl -y
45+
sudo apt-get update -y
46+
sudo apt-get install -y php-xdebug
47+
sudo curl -s https://getcomposer.org/installer | php
48+
sudo mv composer.phar /usr/local/bin/composer
49+
50+
- name: Install dependencies
51+
working-directory: ./test
52+
run: |
53+
composer update
54+
env:
55+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
56+
57+
- name: Init roadrunner server
58+
working-directory: ./test
59+
run: |
60+
sudo ./vendor/bin/rr get
61+
cp ../src/Commands/file/psr-worker.php psr-worker.php
62+
sudo ./rr serve -v -d &
63+
64+
- name: Test with PHPUnit
65+
working-directory: ./test
66+
run: script -e -c "vendor/bin/phpunit -v"
67+
env:
68+
TERM: xterm-256color

src/Ci4FileBridge.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ class Ci4FileBridge
99

1010
public function __construct(array $rFiles)
1111
{
12-
$this->_rFiles = $rFiles;
13-
$_FILES = [];
12+
$this->_rFiles = &$rFiles;
1413
}
1514

1615
public function setFile(){
17-
$this->handleFile();
16+
if(env("CIROAD_TEMP_UPLOAD")){
17+
$this->handleFile();
18+
}
19+
$GLOBALS["psr7Files"] = &$this->_rFiles;
1820
}
1921

2022
private function handleFile()

src/Commands/file/env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#--------------------------------------------------------------------
2+
# CodeIgniter4-RoadRunner
3+
#--------------------------------------------------------------------
4+
5+
# CIROAD_TEMP_UPLOAD = true

src/Commands/file/psr-worker.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ function is_cli(): bool{
4444
$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT));
4545
$psr7 = new RoadRunner\PSR7Client($worker);
4646

47+
/**
48+
* PSR-File object global variable
49+
*/
50+
$psr7Files;
51+
4752
/**
4853
* Dump given value into target output.
4954
*
@@ -130,4 +135,6 @@ function init()
130135
$appConfig = config(\Config\App::class);
131136
$app = new \CodeIgniter\CodeIgniter($appConfig);
132137
$app->initialize();
138+
$_FILES = [];
139+
$GLOBALS["psr7Files"] = null;
133140
}

test/.env

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#--------------------------------------------------------------------
2+
# Example Environment Configuration file
3+
#
4+
# This file can be used as a starting point for your own
5+
# custom .env files, and contains most of the possible settings
6+
# available in a default install.
7+
#
8+
# By default, all of the settings are commented out. If you want
9+
# to override the setting, you must un-comment it by removing the '#'
10+
# at the beginning of the line.
11+
#--------------------------------------------------------------------
12+
13+
#--------------------------------------------------------------------
14+
# ENVIRONMENT
15+
#--------------------------------------------------------------------
16+
17+
# CI_ENVIRONMENT = development
18+
19+
#--------------------------------------------------------------------
20+
# APP
21+
#--------------------------------------------------------------------
22+
23+
app.baseURL = 'http://localhost:8080/'
24+
# app.forceGlobalSecureRequests = false
25+
26+
# app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
27+
# app.sessionCookieName = 'ci_session'
28+
# app.sessionSavePath = NULL
29+
# app.sessionMatchIP = false
30+
# app.sessionTimeToUpdate = 300
31+
# app.sessionRegenerateDestroy = false
32+
33+
# app.cookiePrefix = ''
34+
# app.cookieDomain = ''
35+
# app.cookiePath = '/'
36+
# app.cookieSecure = false
37+
# app.cookieHTTPOnly = false
38+
39+
# app.CSRFProtection = false
40+
# app.CSRFTokenName = 'csrf_test_name'
41+
# app.CSRFCookieName = 'csrf_cookie_name'
42+
# app.CSRFExpire = 7200
43+
# app.CSRFRegenerate = true
44+
# app.CSRFExcludeURIs = []
45+
46+
# app.CSPEnabled = false
47+
48+
#--------------------------------------------------------------------
49+
# DATABASE
50+
#--------------------------------------------------------------------
51+
52+
# database.default.hostname = localhost
53+
# database.default.database = ci4
54+
# database.default.username = root
55+
# database.default.password = root
56+
# database.default.DBDriver = MySQLi
57+
58+
# database.tests.hostname = localhost
59+
# database.tests.database = ci4
60+
# database.tests.username = root
61+
# database.tests.password = root
62+
# database.tests.DBDriver = MySQLi
63+
64+
#--------------------------------------------------------------------
65+
# CONTENT SECURITY POLICY
66+
#--------------------------------------------------------------------
67+
68+
# contentsecuritypolicy.reportOnly = false
69+
# contentsecuritypolicy.defaultSrc = 'none'
70+
# contentsecuritypolicy.scriptSrc = 'self'
71+
# contentsecuritypolicy.styleSrc = 'self'
72+
# contentsecuritypolicy.imageSrc = 'self'
73+
# contentsecuritypolicy.base_uri = null
74+
# contentsecuritypolicy.childSrc = null
75+
# contentsecuritypolicy.connectSrc = 'self'
76+
# contentsecuritypolicy.fontSrc = null
77+
# contentsecuritypolicy.formAction = null
78+
# contentsecuritypolicy.frameAncestors = null
79+
# contentsecuritypolicy.mediaSrc = null
80+
# contentsecuritypolicy.objectSrc = null
81+
# contentsecuritypolicy.pluginTypes = null
82+
# contentsecuritypolicy.reportURI = null
83+
# contentsecuritypolicy.sandbox = false
84+
# contentsecuritypolicy.upgradeInsecureRequests = false
85+
86+
#--------------------------------------------------------------------
87+
# HONEYPOT
88+
#--------------------------------------------------------------------
89+
90+
# honeypot.hidden = 'true'
91+
# honeypot.label = 'Fill This Field'
92+
# honeypot.name = 'honeypot'
93+
# honeypot.template = '<label>{label}</label><input type="text" name="{name}" value=""/>'
94+
95+
#--------------------------------------------------------------------
96+
# CodeIgniter4-RoadRunner
97+
#--------------------------------------------------------------------
98+
99+
CIROAD_TEMP_UPLOAD = true

test/.gitignore

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#-------------------------
2+
# Operating Specific Junk Files
3+
#-------------------------
4+
5+
# OS X
6+
.DS_Store
7+
.AppleDouble
8+
.LSOverride
9+
10+
# OS X Thumbnails
11+
._*
12+
13+
# Windows image file caches
14+
Thumbs.db
15+
ehthumbs.db
16+
Desktop.ini
17+
18+
# Recycle Bin used on file shares
19+
$RECYCLE.BIN/
20+
21+
# Windows Installer files
22+
*.cab
23+
*.msi
24+
*.msm
25+
*.msp
26+
27+
# Windows shortcuts
28+
*.lnk
29+
30+
# Linux
31+
*~
32+
33+
# KDE directory preferences
34+
.directory
35+
36+
# Linux trash folder which might appear on any partition or disk
37+
.Trash-*
38+
39+
#-------------------------
40+
# Environment Files
41+
#-------------------------
42+
# These should never be under version control,
43+
# as it poses a security risk.
44+
# .env
45+
.vagrant
46+
Vagrantfile
47+
48+
#-------------------------
49+
# Temporary Files
50+
#-------------------------
51+
writable/cache/*
52+
!writable/cache/index.html
53+
54+
writable/logs/*
55+
!writable/logs/index.html
56+
57+
writable/session/*
58+
!writable/session/index.html
59+
60+
writable/uploads/*
61+
!writable/uploads/index.html
62+
63+
writable/debugbar/*
64+
65+
php_errors.log
66+
67+
#-------------------------
68+
# User Guide Temp Files
69+
#-------------------------
70+
user_guide_src/build/*
71+
user_guide_src/cilexer/build/*
72+
user_guide_src/cilexer/dist/*
73+
user_guide_src/cilexer/pycilexer.egg-info/*
74+
75+
#-------------------------
76+
# Test Files
77+
#-------------------------
78+
tests/coverage*
79+
80+
# Don't save phpunit under version control.
81+
phpunit
82+
83+
#-------------------------
84+
# Composer
85+
#-------------------------
86+
vendor/
87+
composer.lock
88+
89+
#-------------------------
90+
# IDE / Development Files
91+
#-------------------------
92+
93+
# Modules Testing
94+
_modules/*
95+
96+
# phpenv local config
97+
.php-version
98+
99+
# Jetbrains editors (PHPStorm, etc)
100+
.idea/
101+
*.iml
102+
103+
# Netbeans
104+
nbproject/
105+
build/
106+
nbbuild/
107+
dist/
108+
nbdist/
109+
nbactions.xml
110+
nb-configuration.xml
111+
.nb-gradle/
112+
113+
# Sublime Text
114+
*.tmlanguage.cache
115+
*.tmPreferences.cache
116+
*.stTheme.cache
117+
*.sublime-workspace
118+
*.sublime-project
119+
.phpintel
120+
/api/
121+
122+
# Visual Studio Code
123+
.vscode/
124+
125+
/results/
126+
/phpunit*.xml
127+
/.phpunit.*.cache
128+
129+
#-------------------------
130+
# Roadrunner Files
131+
#-------------------------
132+
rr.exe
133+
psr-worker.php
134+
#.rr.yaml
135+
rr

test/.rr.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
http:
2+
address: 0.0.0.0:8080
3+
workers:
4+
command: "php psr-worker.php"
5+
pool:
6+
numWorkers: 1
7+
maxJobs: 1
8+
9+
static:
10+
enable: true
11+
dir: "public"
12+
forbid: [".php", ".htaccess"]

test/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test Case

test/app/.htaccess

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<IfModule authz_core_module>
2+
Require all denied
3+
</IfModule>
4+
<IfModule !authz_core_module>
5+
Deny from all
6+
</IfModule>

test/app/Common.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* The goal of this file is to allow developers a location
5+
* where they can overwrite core procedural functions and
6+
* replace them with their own. This file is loaded during
7+
* the bootstrap process and is called during the frameworks
8+
* execution.
9+
*
10+
* This can be looked at as a `master helper` file that is
11+
* loaded early on, and may also contain additional functions
12+
* that you'd like to use throughout your entire application
13+
*
14+
* @link: https://codeigniter4.github.io/CodeIgniter4/
15+
*/

0 commit comments

Comments
 (0)