Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3cbe980
Refactor old testing code
parapente Nov 2, 2025
3e50206
Use classes from joomla framework and remove custom class declarations
parapente Nov 2, 2025
a2cd2fb
Fix return type in docblock
parapente Nov 2, 2025
13e1d36
Add docker
parapente Nov 3, 2025
43eb43d
Remove unnecessary file
parapente Nov 4, 2025
58e4d30
Prepare files for docker containers
parapente Nov 4, 2025
3c5f7b1
Allow installation of the component from the joomla cli
parapente Nov 5, 2025
a21ac84
Add cypress and novnc containers
parapente Nov 5, 2025
e3e22c9
Fix file permissions
parapente Nov 5, 2025
3b91d79
Fix novnc and cypress startup
parapente Nov 5, 2025
9f7c9d1
Add db snapshot and make tools for building package
parapente Nov 6, 2025
e528cff
Add tests for checking initial condition of joomla installation
parapente Nov 6, 2025
10b417b
Add test for the extension installation
parapente Nov 6, 2025
5a5efd3
Configure cypress-mysql
parapente Nov 6, 2025
a84b496
Create a new command to disable extensions via database query and dis…
parapente Nov 6, 2025
56a5703
Validate number of packages, components and plugins
parapente Nov 6, 2025
3a24836
Fix typo
parapente Nov 6, 2025
fa05b0d
Remove unnecessary and possibly dangerous code
parapente Nov 6, 2025
08b2577
Don't preinstall extension
parapente Nov 6, 2025
cf6df45
Add test for reinstallation of package
parapente Nov 6, 2025
ed6636f
Actually use the mocks
parapente Nov 9, 2025
c37cffa
Mock database driver
parapente Nov 10, 2025
9dd5788
user Registry with an empty separator
Nov 10, 2025
580bdc6
Add define for _JEXEC
parapente Nov 11, 2025
03c8402
Use filter_var_array instead of filter_var. Fixes importing csv files
parapente Nov 11, 2025
7f7e95b
Prepare database mocks and language setting
parapente Nov 11, 2025
61f1e0a
Fix language strings loading
parapente Nov 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/temp/joomla
/vendor
/node_modules
5 changes: 5 additions & 0 deletions .env.4.4.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JOOMLA_VERSION=4.4-php8.1
JOOMLA_DB_NAME=joomla

MARIADB_VERSION=12
JOOMLA_FRAMEWORK_VERSION=^2.0
5 changes: 5 additions & 0 deletions .env.5.4.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JOOMLA_VERSION=5.4-php8.3
JOOMLA_DB_NAME=joomla

MARIADB_VERSION=12
JOOMLA_FRAMEWORK_VERSION=^3.0
5 changes: 5 additions & 0 deletions .env.6.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JOOMLA_VERSION=6-php8.3
JOOMLA_DB_NAME=joomla

MARIADB_VERSION=12
JOOMLA_FRAMEWORK_VERSION=^4.0
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/unerrnum
/watch*
/vendor
/node_modules
/node_modules
/.phpunit.result.cache
/.phpunit.cache
/.env
12 changes: 0 additions & 12 deletions .svnignore

This file was deleted.

20 changes: 20 additions & 0 deletions FOR_DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [How to update release](#how-to-update-release-version)
- [How to update release package](#how-to-update-release-package)
- [Testing](#testing)

### How to update release version

Expand All @@ -24,3 +25,22 @@ create a release with v<version> as name

upload the package file attachments-<version>.zip into this release


### Testing

This project uses PHPUnit for testing. To run the tests:

1. Install dependencies: `composer install`
2. Run all tests: `composer test` or `make test`
3. Run tests with coverage: `composer test-coverage` or `make test-coverage`

The test suite includes:
- Unit tests for core functionality in `tests/unit/`
- Integration tests in `tests/integration/` (when available)
- Helper tests for the AttachmentsPermissions class and related functionality

To run specific tests:
- `vendor/bin/phpunit tests/unit/Helper/` - Run all helper tests
- `vendor/bin/phpunit --testdox` - Run with human-readable output
- `vendor/bin/phpunit --coverage-html coverage/` - Run with coverage report

13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,19 @@ purge:
@find . -name '*.bak' -exec rm {} \;
@rm -f .tx/*.bak

unittests:
test:
@echo
@echo "Running unit tests..."
@cd test; phing -Droot=/var/www/test/joomla25/ unit_tests
@php vendor/bin/phpunit -c phpunit.xml
@echo

unittests_show: unittests
@firefox test/coverage_result/index.html
test-coverage:
@echo
@echo "Running unit tests with coverage..."
@php vendor/bin/phpunit -c phpunit.xml --coverage-html ./tests/coverage-report
@echo
@echo "Coverage report generated in tests/coverage-report/index.html"
@echo

manual: extensions_manual/manual.rst
@echo "Creating Attachments Extension Manual"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ protected static function parseFieldNames($file)
$field = array();
$header_line = fgetcsv($file);
// Strip of the leading BOM, if present
$header_line = filter_var($header_line, FILTER_DEFAULT , FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
$header_line = filter_var_array($header_line, FILTER_DEFAULT , FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
for ($i = 0; $i < count($header_line); $i++) {
$field_name = trim(strtolower($header_line[$i]));
if (in_array($field_name, AttachmentsImport::$field_names)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AttachmentsPermissions
/**
* Get the actions
*
* @return an array of which actions are permitted for this user
* @return Registry a registry object of which actions are permitted for this user
*/
public static function getActions($user_id = null)
{
Expand All @@ -47,7 +47,7 @@ public static function getActions($user_id = null)
$user = Factory::getApplication()->getIdentity();
}

$result = new Registry();
$result = new Registry(null, "");

$assetName = 'com_attachments';

Expand Down
6 changes: 6 additions & 0 deletions attachments_component/admin/src/Helper/AttachmentsUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class AttachmentsUpdate
public static function checkAccess()
{
$app = Factory::getApplication();

// Skip authorization check in CLI context
if ($app->isClient('cli')) {
return;
}

$user = $app->getIdentity();
if ($user === null or !$user->authorise('core.admin', 'com_attachments')) {
throw new \Exception(Text::_('JERROR_ALERTNOAUTHOR') . ' (ERR 67)', 404);
Expand Down
21 changes: 0 additions & 21 deletions attachments_component/install.attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,27 +200,6 @@ public function preflight(string $type, InstallerAdapter $adapter): bool
return false;
}

// If there is debris from a previous failed attempt to install Attachments, delete it
// NOTE: Creating custom query because using JComponentHelper::isEnabled insists on
// printing a warning if the component is not installed
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('extension_id AS id, enabled');
$query->from('#__extensions');
$query->where($query->qn('type') . ' = ' . $db->quote('component'));
$query->where($query->qn('element') . ' = ' . $db->quote('com_attachments'));
$db->setQuery($query);
if ($db->loadResult() == 0) {
if (
Folder::exists(JPATH_ROOT . '/components/com_attachments')
or Folder::exists(JPATH_ROOT . '/administrator/components/com_attachments')
) {
$msg = Text::_('ATTACH_ERROR_UINSTALL_OLD_VERSION');
$app->enqueueMessage($msg, 'error');
return false;
}
}

// Temporarily move the attachments directory out of the way to avoid conflicts
$attachdir = JPATH_ROOT . '/attachments';
if (Folder::exists($attachdir)) {
Expand Down
31 changes: 25 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
{
"require-dev": {
"phpunit/phpunit": "^10.3",
"phpcompatibility/php-compatibility": "^10.0@dev"
"phpunit/phpunit": "^10.0",
"phpcompatibility/php-compatibility": "^9.0",
"joomla/test": "^4.0",
"joomla/string": "^4.0",
"joomla/registry": "^4.0",
"joomla/database": "^4.0",
"joomla/application": "^4.0",
"joomla/di": "^4.0",
"joomla/session": "^4.0",
"joomla/language": "^4.0",
"joomla/filter": "^4.0",
"joomla/filesystem": "^4.1"
},
"autoload": {
"psr-4": {
"JMCameron\\Component\\Attachments\\Administrator\\": "attachments_component/admin/src/",
"JMCameron\\Component\\Attachments\\Site\\": "attachments_component/site/src/"
}
},
"autoload-dev": {
"Tests\\": "tests",
"JMCameron\\Component\\Attachments\\Administrator\\": "attachments_component/admin/src/",
"JMCameron\\Component\\Attachments\\Site\\": "attachments_component/site/src/"
"psr-4": {
"Tests\\": "tests/",
"Joomla\\CMS\\": "temp/joomla/libraries/src/"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"check-compatibility": "phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 7.4- --ignore=*/vendor/*,temp/*"
"check-compatibility": "phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 7.4- --ignore=*/vendor/*,temp/*",
"test": "phpunit -c phpunit.xml",
"test-coverage": "phpunit -c phpunit.xml --coverage-html ./tests/coverage-report"
}
}
Loading