Skip to content

Commit 810f483

Browse files
authored
Merge pull request #209 from Kit/fix-tests-wc-9.7
Tests: Update Stripe steps for WooCommerce 9.7.0+
2 parents 7d22150 + ad50c52 commit 810f483

17 files changed

+166
-145
lines changed

.env.dist.testing

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TEST_SITE_ADMIN_USERNAME=admin
88
TEST_SITE_ADMIN_PASSWORD=password
99
TEST_SITE_ADMIN_EMAIL="[email protected]"
1010
TEST_SITE_WP_ADMIN_PATH=/wp-admin
11-
WP_ROOT_FOLDER="/home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress"
11+
WP_ROOT_FOLDER="/var/www/html"
1212
TEST_DB_NAME=test
1313
TEST_DB_HOST=localhost
1414
TEST_DB_USER=root

.github/workflows/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
# Virtual Environment to use.
1919
# @see: https://github.com/actions/virtual-environments
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-latest
2121

2222
# Environment Variables.
2323
# Accessible by using ${{ env.NAME }}

.github/workflows/deploy-readme.yml

-18
This file was deleted.

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
# Virtual Environment to use
1313
# @see: https://github.com/actions/virtual-environments
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515

1616
# Steps to deploy
1717
steps:

.github/workflows/test-backward-compat.yml

+69-18
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717

1818
# Virtual Environment to use.
1919
# @see: https://github.com/actions/virtual-environments
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-latest
2121

2222
# Environment Variables.
2323
# Accessible by using ${{ env.NAME }}
2424
# Use ${{ secrets.NAME }} to include any GitHub Secrets in ${{ env.NAME }}
2525
# The base folder will always be /home/runner/work/github-repo-name/github-repo-name
2626
env:
27-
ROOT_DIR: /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress
28-
PLUGIN_DIR: /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-content/plugins/convertkit-woocommerce
27+
ROOT_DIR: /var/www/html
28+
PLUGIN_DIR: /var/www/html/wp-content/plugins/convertkit-woocommerce
2929
DB_NAME: test
3030
DB_USER: root
3131
DB_PASS: root
@@ -72,6 +72,13 @@ jobs:
7272
replace: '-'
7373
replaceAll: true
7474

75+
# Checkout Plugin to /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocmmerce
76+
# We cannot checkout to ${{ env.PLUGIN_DIR }} as GitHub Actions require it be first placed in /home/runner/work/repo/repo
77+
- name: Checkout Plugin
78+
uses: actions/checkout@v4
79+
with:
80+
path: /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocommerce
81+
7582
- name: Start MySQL
7683
run: sudo systemctl start mysql.service
7784

@@ -86,17 +93,15 @@ jobs:
8693

8794
# Some workflows checkout WordPress from GitHub, but that seems to bring a bunch of uncompiled files with it.
8895
# Instead download from wordpress.org stable.
89-
- name: Download WordPress
90-
run: wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
91-
92-
- name: Extract WordPress
93-
run: tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
94-
95-
# Checkout (copy) this repository's Plugin to this VM.
96-
- name: Checkout Plugin
97-
uses: actions/checkout@v4
98-
with:
99-
path: ${{ env.PLUGIN_DIR }}
96+
- name: Download and Extract WordPress
97+
run: |
98+
sudo chown -R runner:docker /var/www/html
99+
ls -la /var/www/html
100+
cd /var/www/html
101+
wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
102+
tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
103+
mv wordpress/* .
104+
rm -rf wordpress wordpress-${{ matrix.wp-versions }}.tar.gz
100105
101106
# We install WP-CLI, as it provides useful commands to setup and install WordPress through the command line.
102107
- name: Install WP-CLI
@@ -132,6 +137,10 @@ jobs:
132137
- name: Install Paid Third Party WordPress Plugins
133138
working-directory: ${{ env.ROOT_DIR }}
134139
run: wp-cli plugin install ${{ secrets.CONVERTKIT_PAID_PLUGIN_URLS }}
140+
141+
# Move Plugin
142+
- name: Move Plugin
143+
run: mv /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocommerce ${{ env.PLUGIN_DIR }}
135144

136145
# WP_DEBUG = true is required so all PHP errors are output and caught by tests (E_ALL).
137146
# WP_DEBUG = false for PHP 8.1+, otherwise E_DEPRECATED is output due to WooCommerce.
@@ -156,10 +165,37 @@ jobs:
156165
php-version: ${{ matrix.php-versions }}
157166
coverage: xdebug
158167

159-
# Make sure that an nginx configuration file exists in this repository at tests/nginx/php-x.x.conf.
160-
# Refer to an existing .conf file in this repository if you need to create a new one e.g. for a new PHP version.
161-
- name: Copy nginx configuration file
162-
run: sudo cp ${{ env.PLUGIN_DIR }}/tests/nginx/php-${{ matrix.php-versions }}.conf /etc/nginx/conf.d/php-${{ matrix.php-versions }}.conf
168+
# Configure nginx to use the PHP version and WOrdPress installation at /var/www/html
169+
- name: Configure nginx site
170+
run: |
171+
sudo rm -f /etc/nginx/sites-enabled/default
172+
sudo tee /etc/nginx/sites-available/default > /dev/null << 'EOF'
173+
174+
server {
175+
listen 80 default_server;
176+
listen [::]:80 default_server;
177+
178+
root /var/www/html;
179+
index index.php;
180+
181+
server_name localhost;
182+
183+
location / {
184+
try_files $uri $uri/ /index.php?$args;
185+
}
186+
187+
location ~ \.php$ {
188+
include snippets/fastcgi-php.conf;
189+
fastcgi_pass unix:/run/php/php${{ matrix.php-versions }}-fpm.sock;
190+
}
191+
192+
location ~ /\.ht {
193+
deny all;
194+
}
195+
}
196+
EOF
197+
198+
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default || true
163199
164200
- name: Test nginx
165201
run: sudo nginx -t
@@ -209,6 +245,21 @@ jobs:
209245
working-directory: ${{ env.PLUGIN_DIR }}
210246
run: composer dump-autoload
211247

248+
# This ensures that applicable files and folders can be written to by WordPress and cache Plugins.
249+
- name: Set File and Folder Permissions
250+
run: |
251+
sudo chmod 767 ${{ env.ROOT_DIR }}
252+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}
253+
254+
sudo chmod 767 ${{ env.ROOT_DIR }}/wp-config.php
255+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-config.php
256+
257+
sudo chmod 767 ${{ env.ROOT_DIR }}/wp-content
258+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content
259+
260+
sudo chmod -R 767 ${{ env.ROOT_DIR }}/wp-content/uploads
261+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content/uploads
262+
212263
# This ensures the Plugin's log file can be written to.
213264
# We don't recursively do this, as it'll prevent Codeception from writing to the /tests/_output directory.
214265
- name: Set Permissions for Plugin Directory

.github/workflows/test.yml

+69-18
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717

1818
# Virtual Environment to use.
1919
# @see: https://github.com/actions/virtual-environments
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-latest
2121

2222
# Environment Variables.
2323
# Accessible by using ${{ env.NAME }}
2424
# Use ${{ secrets.NAME }} to include any GitHub Secrets in ${{ env.NAME }}
2525
# The base folder will always be /home/runner/work/github-repo-name/github-repo-name
2626
env:
27-
ROOT_DIR: /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress
28-
PLUGIN_DIR: /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-content/plugins/convertkit-woocommerce
27+
ROOT_DIR: /var/www/html
28+
PLUGIN_DIR: /var/www/html/wp-content/plugins/convertkit-woocommerce
2929
DB_NAME: test
3030
DB_USER: root
3131
DB_PASS: root
@@ -77,6 +77,13 @@ jobs:
7777
replace: '-'
7878
replaceAll: true
7979

80+
# Checkout Plugin to /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocmmerce
81+
# We cannot checkout to ${{ env.PLUGIN_DIR }} as GitHub Actions require it be first placed in /home/runner/work/repo/repo
82+
- name: Checkout Plugin
83+
uses: actions/checkout@v4
84+
with:
85+
path: /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocommerce
86+
8087
- name: Start MySQL
8188
run: sudo systemctl start mysql.service
8289

@@ -91,17 +98,15 @@ jobs:
9198

9299
# Some workflows checkout WordPress from GitHub, but that seems to bring a bunch of uncompiled files with it.
93100
# Instead download from wordpress.org stable.
94-
- name: Download WordPress
95-
run: wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
96-
97-
- name: Extract WordPress
98-
run: tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
99-
100-
# Checkout (copy) this repository's Plugin to this VM.
101-
- name: Checkout Plugin
102-
uses: actions/checkout@v4
103-
with:
104-
path: ${{ env.PLUGIN_DIR }}
101+
- name: Download and Extract WordPress
102+
run: |
103+
sudo chown -R runner:docker /var/www/html
104+
ls -la /var/www/html
105+
cd /var/www/html
106+
wget https://wordpress.org/wordpress-${{ matrix.wp-versions }}.tar.gz
107+
tar xfz wordpress-${{ matrix.wp-versions }}.tar.gz
108+
mv wordpress/* .
109+
rm -rf wordpress wordpress-${{ matrix.wp-versions }}.tar.gz
105110
106111
# We install WP-CLI, as it provides useful commands to setup and install WordPress through the command line.
107112
- name: Install WP-CLI
@@ -137,6 +142,10 @@ jobs:
137142
- name: Install Paid Third Party WordPress Plugins
138143
working-directory: ${{ env.ROOT_DIR }}
139144
run: wp-cli plugin install ${{ secrets.CONVERTKIT_PAID_PLUGIN_URLS }}
145+
146+
# Move Plugin
147+
- name: Move Plugin
148+
run: mv /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/convertkit-woocommerce ${{ env.PLUGIN_DIR }}
140149

141150
# WP_DEBUG = true is required so all PHP errors are output and caught by tests (E_ALL).
142151
# WP_DEBUG = false for PHP 8.1+, otherwise E_DEPRECATED is output due to WooCommerce.
@@ -161,10 +170,37 @@ jobs:
161170
php-version: ${{ matrix.php-versions }}
162171
coverage: xdebug
163172

164-
# Make sure that an nginx configuration file exists in this repository at tests/nginx/php-x.x.conf.
165-
# Refer to an existing .conf file in this repository if you need to create a new one e.g. for a new PHP version.
166-
- name: Copy nginx configuration file
167-
run: sudo cp ${{ env.PLUGIN_DIR }}/tests/nginx/php-${{ matrix.php-versions }}.conf /etc/nginx/conf.d/php-${{ matrix.php-versions }}.conf
173+
# Configure nginx to use the PHP version and WOrdPress installation at /var/www/html
174+
- name: Configure nginx site
175+
run: |
176+
sudo rm -f /etc/nginx/sites-enabled/default
177+
sudo tee /etc/nginx/sites-available/default > /dev/null << 'EOF'
178+
179+
server {
180+
listen 80 default_server;
181+
listen [::]:80 default_server;
182+
183+
root /var/www/html;
184+
index index.php;
185+
186+
server_name localhost;
187+
188+
location / {
189+
try_files $uri $uri/ /index.php?$args;
190+
}
191+
192+
location ~ \.php$ {
193+
include snippets/fastcgi-php.conf;
194+
fastcgi_pass unix:/run/php/php${{ matrix.php-versions }}-fpm.sock;
195+
}
196+
197+
location ~ /\.ht {
198+
deny all;
199+
}
200+
}
201+
EOF
202+
203+
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default || true
168204
169205
- name: Test nginx
170206
run: sudo nginx -t
@@ -214,6 +250,21 @@ jobs:
214250
working-directory: ${{ env.PLUGIN_DIR }}
215251
run: composer dump-autoload
216252

253+
# This ensures that applicable files and folders can be written to by WordPress and cache Plugins.
254+
- name: Set File and Folder Permissions
255+
run: |
256+
sudo chmod 767 ${{ env.ROOT_DIR }}
257+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}
258+
259+
sudo chmod 767 ${{ env.ROOT_DIR }}/wp-config.php
260+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-config.php
261+
262+
sudo chmod 767 ${{ env.ROOT_DIR }}/wp-content
263+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content
264+
265+
sudo chmod -R 767 ${{ env.ROOT_DIR }}/wp-content/uploads
266+
sudo chown www-data:www-data ${{ env.ROOT_DIR }}/wp-content/uploads
267+
217268
# This ensures the Plugin's log file can be written to.
218269
# We don't recursively do this, as it'll prevent Codeception from writing to the /tests/_output directory.
219270
- name: Set Permissions for Plugin Directory

admin/class-ckwc-admin-ajax.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function sync_past_orders() {
5151
}
5252

5353
// Get ID.
54-
$id = absint( sanitize_text_field( $_REQUEST['id'] ) );
54+
$id = absint( sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ) );
5555

5656
// Fetch integration.
5757
$this->integration = WP_CKWC_Integration();

admin/class-ckwc-admin-bulk-edit.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,17 @@ public function bulk_edit_save() {
9292
}
9393

9494
// Bail if the value is -1, as this means don't change the setting.
95-
if ( sanitize_text_field( $_REQUEST['ckwc_subscription'] ) === '-1' ) {
95+
if ( sanitize_text_field( wp_unslash( $_REQUEST['ckwc_subscription'] ) ) === '-1' ) {
96+
return;
97+
}
98+
99+
// Bail if the Post Type or Post IDs are not specified.
100+
if ( ! isset( $_REQUEST['post_type'] ) || ! isset( $_REQUEST['post'] ) ) {
96101
return;
97102
}
98103

99104
// Get Post Type object.
100-
$post_type = get_post_type_object( $_REQUEST['post_type'] );
105+
$post_type = get_post_type_object( sanitize_text_field( wp_unslash( $_REQUEST['post_type'] ) ) );
101106

102107
// Bail if the logged in user cannot edit Pages/Posts.
103108
if ( ! current_user_can( $post_type->cap->edit_posts ) ) {

0 commit comments

Comments
 (0)