Skip to content

Commit 6df5405

Browse files
authored
Merge pull request #37 from Rahulsingh1939/main
Added Testing, Documentation, and Improvements for PHP 8.2 compatibility & DB handling
2 parents ff4c029 + 2c7e275 commit 6df5405

File tree

75 files changed

+10242
-189
lines changed

Some content is hidden

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

75 files changed

+10242
-189
lines changed

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Joomla Testing Environment Configuration
2+
# Copy this file to .env and update with your actual values
3+
4+
# Joomla Base URL (without trailing slash)
5+
JOOMLA_BASE_URL=http://localhost/joomla
6+
7+
# Joomla Administrator Credentials
8+
JOOMLA_ADMIN_USER=admin
9+
JOOMLA_ADMIN_PASS=admin123

.github/workflows/ci.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: CI and Release
2+
3+
on:
4+
push:
5+
branches: [main, cypress-testing-beta]
6+
pull_request:
7+
branches: [main, cypress-testing-beta]
8+
release:
9+
types: [published] # runs only when a release is published in GitHub UI
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
services:
16+
mysql:
17+
image: mysql:8
18+
env:
19+
MYSQL_ROOT_PASSWORD: root
20+
MYSQL_DATABASE: joomla
21+
ports:
22+
- 3306:3306
23+
options: >-
24+
--health-cmd="mysqladmin ping -h localhost -uroot -proot"
25+
--health-interval=10s
26+
--health-timeout=5s
27+
--health-retries=5
28+
29+
joomla:
30+
image: joomla:6.0-php8.3-apache
31+
env:
32+
JOOMLA_DB_HOST: mysql
33+
JOOMLA_DB_USER: root
34+
JOOMLA_DB_PASSWORD: root
35+
JOOMLA_DB_NAME: joomla
36+
ports:
37+
- 8080:80
38+
options: >-
39+
--health-cmd="curl -f http://localhost/installation/index.php || exit 1"
40+
--health-interval=15s
41+
--health-timeout=10s
42+
--health-retries=20
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Setup PHP
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: "8.3"
51+
extensions: zip, mysqli, pdo_mysql
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: "20.11.1"
57+
58+
- name: Install Composer dependencies
59+
run: composer install --no-progress --prefer-dist --optimize-autoloader
60+
61+
- name: Install NPM dependencies
62+
run: npm install
63+
64+
- name: Install zip utility
65+
run: sudo apt-get update && sudo apt-get install -y zip
66+
67+
- name: Wait for Joomla installer to be ready
68+
run: |
69+
for i in {1..40}; do
70+
if curl -f http://localhost:8080/installation/index.php > /dev/null 2>&1; then
71+
echo "✅ Joomla installer is ready"
72+
break
73+
fi
74+
echo "⏳ Waiting for Joomla installer..."
75+
sleep 10
76+
done
77+
78+
- name: Set Joomla env
79+
run: |
80+
echo "JOOMLA_BASE_URL=http://localhost:8080" >> $GITHUB_ENV
81+
echo "JOOMLA_ADMIN_USER=admin" >> $GITHUB_ENV
82+
echo "JOOMLA_ADMIN_PASS=admin123423454664@" >> $GITHUB_ENV
83+
84+
- name: Run tests
85+
run: composer test
86+
env:
87+
JOOMLA_BASE_URL: http://localhost:8080
88+
JOOMLA_ADMIN_USER: admin
89+
JOOMLA_ADMIN_PASS: admin123423454664@
90+
DBUS_SESSION_BUS_ADDRESS: /dev/null
91+
92+
- name: Upload screenshots on failure
93+
if: always()
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: test-screenshots
97+
path: cypress/screenshots
98+
99+
- name: Upload videos on failure
100+
if: always()
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: test-videos
104+
path: cypress/videos
105+
106+
release:
107+
runs-on: ubuntu-latest
108+
needs: test
109+
if: github.event_name == 'release'
110+
111+
steps:
112+
- uses: actions/checkout@v4
113+
with:
114+
fetch-depth: 0 # fetch full history so branches & tags are available
115+
116+
- name: Switch to main branch properly
117+
run: |
118+
git fetch origin main
119+
git checkout -B main origin/main
120+
121+
- name: Extract version from release tag
122+
id: version
123+
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
124+
125+
- name: Create component zip with version
126+
run: |
127+
mkdir -p cypress/fixtures
128+
cd src/component
129+
zip -r ../../cypress/fixtures/com_cmsmigrator_v${{ steps.version.outputs.version }}.zip .
130+
131+
- name: Verify zip file exists
132+
run: ls -lh cypress/fixtures/
133+
134+
- name: Update XML version
135+
run: |
136+
sed -i "s|<version>.*</version>|<version>${{ steps.version.outputs.version }}</version>|" src/component/cmsmigrator.xml
137+
138+
- name: Commit version update
139+
run: |
140+
git config --local user.email "[email protected]"
141+
git config --local user.name "GitHub Action"
142+
git add src/component/cmsmigrator.xml
143+
git commit -m "Bump version to ${{ steps.version.outputs.version }}" || echo "No changes to commit"
144+
git push origin main
145+
146+
- name: Upload asset to GitHub Release
147+
run: |
148+
gh release upload ${{ github.event.release.tag_name }} cypress/fixtures/com_cmsmigrator_v${{ steps.version.outputs.version }}.zip --clobber
149+
env:
150+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@
1111
*.tar
1212
*.zip
1313

14-
# Logs and databases #
15-
######################
14+
# Logs and databases
1615
*.log
1716
*.sqlite
1817

19-
# Temporary files #
20-
###################
18+
# Temporary files
2119
*.swp
2220
*.swap
2321
*.bak
2422

25-
# OS generated files #
26-
######################
23+
# OS generated files
2724
.DS_Store
2825
.DS_Store?
2926
._*
@@ -36,22 +33,63 @@ Thumbs.db
3633
/.idea
3734
.idea
3835

39-
# Composer #
40-
############
41-
vendor
42-
composer.lock
43-
node_modules
36+
# Composer
37+
/vendor/
38+
/composer.lock
39+
40+
# Node (npm/yarn/pnpm)
41+
/node_modules/
4442

45-
# Phing related #
46-
#################
43+
# Phing related
4744
build/ftp.build.properties
4845
build/paths.build.properties
4946

50-
# Visual Code #
51-
###############
52-
.vscode
47+
# Visual Studio Code
48+
.vscode/
49+
50+
# PHPUnit tests
51+
/phpunit.xml
52+
/tests/coverage/
53+
.phpunit.result.cache
54+
55+
# Test files that should be ignored
56+
/tests/temp/
57+
/tests/tmp/
58+
/tests/unit/temp/
59+
/tests/unit/tmp/
60+
/tests/cache/
61+
*.test.tmp
62+
test*.tmp
63+
64+
# Coverage reports
65+
/coverage/
66+
/tests/coverage/
67+
coverage.xml
68+
clover.xml
69+
coverage.clover
70+
71+
# Cypress tests
72+
/cypress/videos/
73+
/cypress/screenshots/
74+
/cypress/results/
75+
/cypress/downloads/
76+
/cypress/reports/
77+
78+
# Media uploads and temporary files
79+
/media/com_cmsmigrator/imports/
80+
/media/com_cmsmigrator/temp/
81+
/media/com_cmsmigrator/cache/
82+
/media/com_cmsmigrator/uploads/
83+
84+
# Runtime and cache files
85+
/cache/
86+
/tmp/
87+
*.cache
88+
.cache/
89+
90+
# Build artifacts
91+
com_cmsmigrator.zip
92+
*.zip.backup
5393

54-
# Tests #
55-
#########
56-
/tests/coverage
57-
phpunit.xml
94+
# Environment files
95+
.env

composer.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
"name": "binary/cms-migrator",
33
"description": "Advanced Migration Tool for Joomla - Migrate from WordPress and other CMS platforms",
44
"type": "joomla-component",
5-
"keywords": ["joomla", "migration", "wordpress", "cms", "import"],
5+
"keywords": [
6+
"joomla",
7+
"migration",
8+
"wordpress",
9+
"cms",
10+
"import"
11+
],
612
"license": "GPL-2.0-or-later",
713
"require": {
814
"php": ">=7.4.0",
@@ -14,7 +20,23 @@
1420
"Binary\\Component\\CmsMigrator\\": "src/component/admin/src/"
1521
}
1622
},
17-
"extra": {
18-
"joomla-component-name": "com_cmsmigrator"
23+
"require-dev": {
24+
"phpunit/phpunit": "^10",
25+
"joomla/test": "^2",
26+
"mockery/mockery": "^1.6"
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"Binary\\Component\\CmsMigrator\\Tests\\": "tests/"
31+
}
32+
},
33+
"scripts": {
34+
"test:syntax": "php ./tests/check_syntax.php",
35+
"test:unit": "phpunit --colors=always",
36+
"test": [
37+
"@test:syntax",
38+
"@test:unit",
39+
"npm test"
40+
]
1941
}
20-
}
42+
}

cypress.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { defineConfig } = require("cypress");
2+
require("dotenv").config();
3+
4+
module.exports = defineConfig({
5+
e2e: {
6+
baseUrl: process.env.JOOMLA_BASE_URL || "http://localhost:8080",
7+
specPattern: "tests/e2e/**/*.cy.{js,jsx,ts,tsx}",
8+
supportFile: "tests/support/e2e.js",
9+
env: {
10+
joomlaBaseUrl: process.env.JOOMLA_BASE_URL || "http://localhost:8080" ,
11+
joomlaAdminUser: process.env.JOOMLA_ADMIN_USER || "admin",
12+
joomlaAdminPass: process.env.JOOMLA_ADMIN_PASS || "admin123",
13+
},
14+
setupNodeEvents(on, config) {
15+
return config;
16+
},
17+
},
18+
});

cypress/fixtures/invalid.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "1.0",
3+
"content": {
4+
"articles": [
5+
{
6+
"title": "Invalid Article",
7+
"alias": "invalid-article",
8+
"introtext": "This article has invalid data.",
9+
"state": "invalid_state",
10+
"catid": "invalid_cat",
11+
"created": "invalid_date",
12+
"created_by": "invalid_user"
13+
}
14+
]
15+
}
16+
}

cypress/fixtures/invalid.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<note>
3+
<to>Lorem Ipsum</to>
4+
<from>Dolor Sit</from>
5+
<heading>Consectetur</heading>
6+
<body>Adipiscing elit. Sed do eiusmod tempor incididunt ut labore.</body>
7+
<extra>Ut enim ad minim veniam
8+
</note>
55.3 KB
Loading
10 KB
Loading
110 KB
Loading

0 commit comments

Comments
 (0)