Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 4b66c31

Browse files
authored
Merge pull request #57 from PhpSlides/main
Initialized PHPUnit test and test workflow - Added URL parameter strict types ✅
2 parents 88c27cf + 2996080 commit 4b66c31

File tree

21 files changed

+376
-121
lines changed

21 files changed

+376
-121
lines changed
File renamed without changes.

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/test export-ignore
1+
/tests export-ignore
22
/.github export-ignore
3+
/.phpunit.cache export-ignore
34
.gitattributes export-ignore
45
.gitignore export-ignore
6+
.phpunit.result.cache export-ignore
57
ChangeLog.md export-ignore

.github/workflows/php.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
php-version: [8.2, 8.3, 8.4]
21+
include:
22+
- php-version: 8.3
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Validate composer.json and composer.lock
29+
run: composer validate --strict
30+
31+
- name: Set up PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php-version }}
35+
extensions: mbstring, intl, curl, dom, fileinfo
36+
tools: composer
37+
38+
- name: Cache Composer packages
39+
id: composer-cache
40+
uses: actions/cache@v3
41+
with:
42+
path: vendor
43+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-php-
46+
47+
- name: Install dependencies
48+
run: composer install --prefer-dist --no-progress
49+
50+
- name: Run Tests
51+
run: composer run-script test

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Configure and Run Tests Before Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
php-version: [8.2, 8.3, 8.4]
21+
include:
22+
- php-version: 8.3
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Validate composer.json and composer.lock
29+
run: composer validate --strict
30+
31+
- name: Set up PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php-version }}
35+
extensions: mbstring, intl, curl, dom, fileinfo
36+
tools: composer
37+
38+
- name: Cache Composer packages
39+
id: composer-cache
40+
uses: actions/cache@v3
41+
with:
42+
path: vendor
43+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-php-
46+
47+
- name: Install dependencies
48+
run: composer install --prefer-dist --no-progress
49+
50+
- name: Run Tests
51+
run: composer run-script test

.github/workflows/tests.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Execute Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
branches:
9+
- dev
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
php-version: [8.2, 8.3, 8.4]
21+
include:
22+
- php-version: 8.3
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php-version }}
32+
extensions: mbstring, intl, curl, dom, fileinfo
33+
tools: composer
34+
35+
- name: Cache Composer packages
36+
id: composer-cache
37+
uses: actions/cache@v3
38+
with:
39+
path: vendor
40+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-php-
43+
44+
- name: Install dependencies
45+
run: composer install --prefer-dist --no-progress
46+
47+
- name: Run Tests
48+
run: composer run-script test
49+
50+
push_to_main:
51+
runs-on: ubuntu-latest
52+
needs: test
53+
if: ${{ success() }}
54+
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Set up git
60+
run: |
61+
git config user.name "github-actions[bot]"
62+
git config user.email "github-actions[bot]@users.noreply.github.com"
63+
64+
- name: Push changes to main
65+
run: |
66+
git fetch origin main dev
67+
git checkout main
68+
git config pull.rebase false
69+
git pull origin main
70+
git merge origin/dev --allow-unrelated-histories --no-ff
71+
git push origin main
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1+
# Ignore the build directory
2+
/build
3+
4+
# Ignore the PHPUnit cache files
5+
/.phpunit.cache
6+
7+
# Ignore the vendor directory, which contains third-party libraries
18
/vendor
9+
10+
# Ignore the access_log file, which logs access information
211
access_log
12+
13+
# Ignore the composer.lock file, which locks the dependencies of the project
314
composer.lock
4-
composer.phar
15+
16+
# Ignore the composer.phar file, which is the Composer binary
17+
composer.phar
18+
19+
# Ignore the PHPUnit result cache file, which stores the results of the last PHPUnit run
20+
.phpunit.result.cache
21+
22+
# Ignore IDE and editor specific files
23+
/.idea
24+
/.vscode
25+
*.swp
26+
27+
# Ignore OS generated files
28+
.DS_Store
29+
Thumbs.db

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# PhpSlides/framework
22

3-
The main code for PhpSlides.
3+
The main code for PhpSlides..

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@
3131
},
3232
"autoload": {
3333
"psr-4": {
34-
"PhpSlides\\": ["src/Exception/"],
35-
"PhpSlides\\Src\\": ["src/"],
36-
"PhpSlides\\Router\\": ["Router/"]
34+
"PhpSlides\\": "src/Exception/",
35+
"PhpSlides\\Src\\": "src/",
36+
"PhpSlides\\Router\\": "Router/"
3737
},
3838
"files": ["src/Bootstrap/App.php"]
3939
},
4040
"autoload-dev": {
4141
"psr-4": {
42-
"PhpSlides\\Tests\\": "tests/"
42+
"PhpSlides\\Tests\\": "tests/tests/"
4343
}
4444
},
4545
"config": {
4646
"preferred-install": "dist"
4747
},
4848
"scripts": {
49-
"test": "phpunit"
49+
"test": "vendor/bin/phpunit",
50+
"phpunit": "php vendor/bin/phpunit"
5051
},
5152
"minimum-stability": "stable",
5253
"prefer-stable": true

phpunit.xml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
<phpunit>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
4+
beStrictAboutTestsThatDoNotTestAnything="false"
5+
colors="true"
6+
stopOnFailure="false"
7+
backupGlobals="false"
8+
bootstrap="vendor/autoload.php"
9+
cacheDirectory=".phpunit.cache"
10+
backupStaticProperties="false">
211
<testsuites>
3-
<testsuite name="Tests PhpSlides Framework">
4-
<directory>./test/PHPUnit</directory>
12+
<testsuite name="PhpSlides Test Suite">
13+
<directory>tests/tests</directory>
514
</testsuite>
615
</testsuites>
7-
<bootstrap>vendor/autoload.php</bootstrap>
16+
17+
<php>
18+
<env name="APP_NAME" value="PhpSlides"/>
19+
<env name="APP_VERSION" value="1.4.3"/>
20+
</php>
821
</phpunit>

src/Cli/Configure.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PhpSlides\Src\Cli;
4+
5+
trait Configure
6+
{
7+
protected static function bootstrap()
8+
{
9+
if (php_sapi_name() == 'cli') {
10+
// Mock necessary $_SERVER variables
11+
$_SERVER['REQUEST_URI'] ??= '/';
12+
$_SERVER['REQUEST_METHOD'] ??= 'GET';
13+
$_SERVER['HTTP_HOST'] ??= 'localhost';
14+
$_SERVER['SERVER_NAME'] ??= 'localhost';
15+
$_SERVER['SERVER_PORT'] ??= '80';
16+
$_SERVER['HTTPS'] ??= 'off';
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)