Skip to content

Commit 53aeb5a

Browse files
committed
Merge branch 'add_arobase'
2 parents 71c39f2 + f6876ea commit 53aeb5a

47 files changed

Lines changed: 6632 additions & 5585 deletions

Some content is hidden

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

.distignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
.gitattributes
66
.gitignore
77
.idea
8-
.lando.yml
8+
.wp-env.override.json
99
.wordpress.org
1010
bin
1111
tests
12-
codeception.dist.yml
1312
composer.json
1413
composer.lock
14+
package.json
15+
package-lock.json
16+
.wp-env.json
1517
grumphp.yml
1618
phpcs.ruleset.xml
1719
phpcs.xml

.env

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
# Base config
2-
WP_ROOT_FOLDER="/app/wordpress/"
2+
WP_ROOT_FOLDER="/var/www/html/"
33
WP_ADMIN_PATH="/wp-admin"
44

55
# Site config
6-
WP_URL="https://beasanitizefilename.lndo.site"
7-
WP_DOMAIN="beasanitizefilename.lndo.site"
6+
WP_URL="http://localhost:8889"
7+
WP_DOMAIN="localhost"
88

99
# database config
1010
DB_NAME="wordpress"
11-
DB_HOST="database"
12-
DB_USER="wordpress"
13-
DB_PASSWORD="wordpress"
11+
DB_HOST="mysql"
12+
DB_USER="root"
13+
DB_PASSWORD="password"
1414
TABLE_PREFIX="wp_"
1515

1616
# Unit Tests
17-
TEST_DB_NAME="wpTests"
18-
TEST_DB_HOST="database"
19-
TEST_DB_USER="wordpress"
20-
TEST_DB_PASSWORD="wordpress"
17+
TEST_DB_NAME="wordpress_test"
18+
TEST_DB_HOST="mysql"
19+
TEST_DB_USER="root"
20+
TEST_DB_PASSWORD="password"
2121
TEST_TABLE_PREFIX="wp_"
2222

2323
# Admin access config
24-
ADMIN_EMAIL="admin@beasanitizefilename.lndo.site"
24+
ADMIN_EMAIL="admin@example.com"
2525
ADMIN_USERNAME=admin
2626
ADMIN_PASSWORD=admin
27-
28-
# BrowserStack
29-
# BROWSERSTACK_USERNAME_REAL=
30-
# BROWSERSTACK_KEY=
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload Release Asset
1+
name: Deploy to WordPress.org
22

33
on:
44
push:
@@ -7,12 +7,12 @@ on:
77
- '*' # Push events to matching *
88

99
jobs:
10-
build:
11-
name: Upload Release Asset
10+
deploy:
11+
name: Deploy to WordPress.org
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616

1717
- name: Publish to WP.org
1818
uses: 10up/action-wordpress-plugin-deploy@stable
@@ -23,12 +23,9 @@ jobs:
2323
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
2424
SLUG: bea-sanitize-filename
2525

26-
- name: Upload Release
27-
uses: actions/upload-release-asset@v1
26+
- name: Upload release asset
27+
uses: softprops/action-gh-release@v2
2828
env:
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
with:
31-
upload_url: ${{ github.event.release.upload_url }}
32-
asset_path: ${{github.workspace}}/${{ github.event.repository.name }}.zip
33-
asset_name: bea-sanitize-filename.zip
34-
asset_content_type: application/zip
31+
files: ${{ github.workspace }}/bea-sanitize-filename.zip

.github/workflows/tests.yml

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,30 @@ name: Tests
22

33
on: [pull_request]
44
jobs:
5-
build:
6-
runs-on: ${{ matrix.operating-system }}
7-
strategy:
8-
fail-fast: false
9-
matrix:
10-
operating-system: [ ubuntu-latest ]
11-
php-versions: [ '7.4' ]
12-
wordpress-versions: [ 'latest', 'nightly', '6.0', '5.9', '5.8', '5.7', '5.6', '5.5']
5+
unit:
6+
runs-on: ubuntu-latest
137

148
steps:
159
- name: "Checkout code"
1610
uses: actions/checkout@v2
1711

18-
- name: "Install docker-ce"
19-
run: |
20-
sudo apt-get update
21-
sudo apt-get install \
22-
apt-transport-https \
23-
ca-certificates \
24-
curl \
25-
gnupg-agent \
26-
software-properties-common
27-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
28-
sudo add-apt-repository \
29-
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
30-
$(lsb_release -cs) \
31-
stable"
32-
sudo apt-get update
33-
sudo apt-get install docker-ce docker-ce-cli containerd.io
34-
35-
- name: "Install Lando"
36-
run: |
37-
wget https://files.devwithlando.io/lando-stable.deb
38-
sudo dpkg -i lando-stable.deb
39-
40-
- name: "Test on ${{ matrix.php-versions }} - ${{ matrix.wordpress-versions }}"
41-
run: |
42-
./bin/ci-env.sh
43-
WP_VERSION=${{ matrix.wordpress-versions }} WP_LOCALE=en_US PHP_VERSION=${{ matrix.php-versions }} ./bin/lando-start.sh
44-
45-
- name: "Run tests"
46-
run: |
47-
lando test
48-
lando stop
12+
- name: "Setup Node.js"
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: "18"
16+
17+
- name: "Install PHP dependencies"
18+
run: composer install --no-interaction --prefer-dist
19+
20+
- name: "Install Node.js dependencies"
21+
run: npm install
22+
23+
- name: "Start wp-env"
24+
run: npm run wp-env:start
25+
26+
- name: "Run unit tests"
27+
run: npm run test:unit
28+
29+
- name: "Stop wp-env"
30+
if: always()
31+
run: npm run wp-env:stop

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/vendor
2+
/node_modules
23
.env.local
34
/wordpress
45

56
codeception.yml
6-
tests/acceptance.suite.yml
7-
tests/functional.suite.yml
8-
tests/unit.suite.yml
9-
tests/wpunit.suite.yml
7+
.wp-env.override.json
8+
.phpunit.result.cache
109

1110
.idea/
1211
.DS_STORE

.lando.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.wp-env.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"core": "WordPress/WordPress",
3+
"phpVersion": "8.0",
4+
"plugins": [
5+
"."
6+
],
7+
"mappings": {
8+
"wp-content/plugins/bea-sanitize-filename": "."
9+
},
10+
"env": {
11+
"tests": {
12+
"phpVersion": "8.0",
13+
"mappings": {
14+
"wp-content/plugins/bea-sanitize-filename": "."
15+
}
16+
}
17+
}
18+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.0.9 - 02 Apr 2026
4+
* Fix invalid smart quotes in special characters list
5+
* Migrate tests to `wp-env` with PHPUnit unit tests only
6+
* Improve testing documentation and scripts
7+
38
## 2.0.8 - 02 Apr 2026
49
* Add `@` character to the sanitized characters list
510

README.md

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# BEA - Sanitize Filename
44

5+
Current version: `2.0.9`
6+
57
This plugin will remove all punctuation and accents from the filename of uploaded files, which is pretty handy.
68
You could then ask "Why it's not already into core?". This is [make WordPress core](https://core.trac.wordpress.org/ticket/22363) !
79

@@ -45,43 +47,44 @@ An [issue](https://github.com/BeAPI/bea-sanitize-filename/issues/1) is open abou
4547

4648
### Introduction
4749

48-
The tests are based on [WP-Browser](https://github.com/lucatume/wp-browser).
50+
The tests are based on PHPUnit and run inside [wp-env](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/).
4951

50-
You have WPUnit and Acceptance tests.
52+
Only unit tests are available.
5153

5254
### Installation
5355

54-
1. Install [Lando](https://docs.devwithlando.io/installation/installing.html)
55-
2. From command line into the project folder execute `./bin/lando-start.sh`
56-
3. From command line into the project folder execute `lando composer install`
57-
58-
The local url will be https://beasanitizefilename.lndo.site and credentials will be
59-
* user : admin
60-
* password : admin
56+
1. Install [Docker](https://www.docker.com/) and [Node.js](https://nodejs.org/) (>= 18)
57+
2. Install dependencies: `npm install && composer install`
58+
3. Run tests: `npm run test:unit`
6159

6260
### Tools
6361
To test the code, just launch :
64-
* For Wpunit tests and desktop : `lando test-local`
65-
* For desktop mobile : `lando test-mobile`
66-
67-
If you need to test the code on BrowserStack, you need to define two environments variables :
68-
* `BROWSERSTACK_USERNAME_REAL` : the usernmae of your browserStack account
69-
* `BROWSERSTACK_KEY` : the key of your browserStack account
70-
71-
/!\ Do not commit theses credentials /!\
72-
73-
## Customization
74-
75-
Need to customize the environment variables ? every codeception file can be overrided bit by bit by creating a new file without the .dist.
76-
So to customize the .env file you'l need to :
77-
78-
* Create a codeception.yml file
79-
* Put into the file :
80-
```
81-
params:
82-
- .env.local
83-
```
84-
* Create a .env.local file and change the desired environment variables like `BROWSERSTACK_KEY`
62+
* For unit tests: `npm run test:unit`
63+
* For a readable report: `npm run test:unit:report`
64+
* For one-shot start + test + stop: `npm run test:unit:once`
65+
66+
### Operating procedure
67+
68+
1. Initialize once on your machine:
69+
- `npm install`
70+
- `composer install`
71+
2. Run test suite:
72+
- `npm run test:unit`
73+
3. Read result directly in terminal output:
74+
- Success: exit code `0` and PHPUnit success line.
75+
- Failure: exit code `1` or `2` with failing test names and stack traces.
76+
4. Stop environment if needed:
77+
- `npm run wp-env:stop`
78+
79+
### Troubleshooting
80+
81+
- Error `service "cli" is not running`:
82+
- `npm run wp-env:start`
83+
- `npm run test:unit`
84+
- If environment is corrupted:
85+
- `npm run wp-env:clean`
86+
- `npm run wp-env:start`
87+
- `npm run test:unit`
8588

8689
## Changelog
8790
Please refer to the [contributing guidelines](.github/CONTRIBUTING.md) to increase the chance of your pull request to be merged and/or receive the best support for your issue.

bea-sanitize-filename.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/*
33
Plugin Name: BEA - Sanitize Filename
4-
Version: 2.0.8
4+
Version: 2.0.9
55
Plugin URI: https://github.com/BeAPI/bea-sanitize-filename
66
Description: Remove all punctuation and accents from the filename of uploaded files.
77
Author: Be API
@@ -38,7 +38,7 @@
3838
*/
3939
function bea_sanitize_file_name_chars( $special_chars = array() ) {
4040
// Special caracters
41-
$special_chars = array_merge( array( ‘’’, ‘’’, ‘”’, ‘”’, ‘«’, ‘»’, ‘‹’, ‘›’, ‘—‘, ‘€’, ‘©’, ‘@’ ), $special_chars );
41+
$special_chars = array_merge( array( '', '', '', '', '«', '»', '', '', '', '', '©', '@' ), $special_chars );
4242
/**
4343
* Accentued caracters
4444
* @see https://github.com/BeAPI/bea-sanitize-filename/issues/8

0 commit comments

Comments
 (0)