Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Tests

on:
pull_request:
branches: [master]
workflow_dispatch:

jobs:
phpunit:
name: PHP ${{ matrix.php }} / WP ${{ matrix.wordpress }}
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
# install.sh always installs latest WooCommerce, which requires WP 6.9+.
wordpress: ['6.9', 'latest']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer, wp-cli

- name: Setup tests
run: |
composer config -g github-oauth.github.com "${{ secrets.ACCESS_TOKEN }}"
composer install --no-interaction
bash tests/bin/install.sh wordpress_test root root 127.0.0.1 ${{ matrix.wordpress }}

- name: Run tests
run: composer test
22 changes: 16 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,29 @@
},
{
"type": "vcs",
"url": "git@github.com:pluginever/framework-model.git"
"url": "git@github.com:byteever/models.git"
}
],
"require": {
"php": ">=7.4",
"pluginever/framework-plugin": "dev-trunk",
"pluginever/framework-model": "dev-trunk",
"pluginever/framework-settings": "dev-trunk"
"pluginever/framework-settings": "dev-trunk",
"byteever/models": "^1.0.0"
},
"require-dev": {
"byteever/byteever-sniffs": "^1.1.3"
"byteever/byteever-sniffs": "^1.1.3",
"phpunit/phpunit": "^9.6",
"wp-phpunit/wp-phpunit": "^6.8",
"yoast/phpunit-polyfills": "^4.0"
},
"autoload": {
"psr-4": {
"WooCommerceSerialNumbers\\": ["includes/","src/"]
"WooCommerceSerialNumbers\\": "includes/"
}
},
"autoload-dev": {
"psr-4": {
"WooCommerceSerialNumbers\\Tests\\": "tests/phpunit/"
}
},
"config": {
Expand All @@ -45,6 +53,8 @@
"makepot": "wp --allow-root i18n make-pot . --include=*.php,assets,includes,templates --domain=wc-serial-numbers",
"phpcs": "php ./vendor/bin/phpcs --standard=phpcs.xml -s -v",
"phpcbf": "php ./vendor/bin/phpcbf --standard=phpcs.xml -v",
"test:setup": "bash ./tests/bin/install.sh wordpress_test root root localhost latest",
"test": "phpunit",
"strauss": [
"test -f /tmp/strauss.phar || curl -o /tmp/strauss.phar -L https://github.com/BrianHenryIE/strauss/releases/download/0.24.1/strauss.phar",
"@php /tmp/strauss.phar",
Expand All @@ -60,7 +70,7 @@
"packages": [
"pluginever/framework-plugin",
"pluginever/framework-settings",
"pluginever/framework-model"
"byteever/models"
]
}
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Actions.php → includes/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function encrypt_key( $data ) {
* @since 1.4.6
*/
public static function enable_product( $key_id ) {
$key = Key::get( $key_id );
$key = Key::find( $key_id );

if ( $key ) {
$product_id = $key->get_product_id();
Expand Down Expand Up @@ -121,7 +121,7 @@ public static function revoke_order_item_keys( $revoke ) {
* @since 1.0.0
*/
public static function update_activation_count( $activation ) {
$key = Key::get( $activation->get_serial_id() );
$key = Key::find( $activation->get_serial_id() );
if ( $key ) {
$key->recount_remaining_activation();
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function process_bulk_actions( $doaction ) {
}

foreach ( $ids as $id ) { // Check the permissions on each.
$key = Activation::get( $id );
$key = Activation::find( $id );
if ( ! $key ) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function process_bulk_actions( $doaction ) {
}

foreach ( $ids as $id ) { // Check the permissions on each.
$key = Key::get( $id );
$key = Key::find( $id );
if ( ! $key ) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Menus.php → includes/Admin/Menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function output_main_page() {
$add = isset( $_GET['add'] ) ? true : false;
$edit = isset( $_GET['edit'] ) ? absint( $_GET['edit'] ) : 0;
if ( $edit ) {
$key = new Key( $edit );
$key = Key::find( $edit );
if ( ! $key->exists() ) {
wp_safe_redirect( remove_query_arg( 'edit' ) );
exit();
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions includes/Admin/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function product_data_tab( $tabs ) {
array(
'label' => __( 'Serial Numbers', 'wc-serial-numbers' ),
'target' => 'wc_serial_numbers_data',
'class' => array( 'show_if_simple', 'hide_if_subscription', 'hide_if_variable-subscription' ),
'class' => array( 'show_if_simple', 'show_if_downloadable', 'hide_if_subscription', 'hide_if_variable-subscription' ),
'priority' => 11,
)
);
Expand All @@ -105,7 +105,7 @@ public static function product_data_tab( $tabs ) {
public static function product_write_panel() {
global $post, $woocommerce;
?>
<div id="wc_serial_numbers_data" class="panel woocommerce_options_panel show_if_simple"
<div id="wc_serial_numbers_data" class="panel woocommerce_options_panel"
style="padding-bottom: 50px;display: none;">
<?php
woocommerce_wp_checkbox(
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Settings.php → includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ protected function output_premium_widget() {
<li>- <?php echo esc_html( $feature ); ?></li>
<?php endforeach; ?>
</ul>
<a href="https://pluginever.com/plugins/woocommerce-serial-numbers-pro/?utm_source=plugin-settings&utm_medium=banner&utm_campaign=upgrade&utm_id=wc-serial-numbers" class="button" target="_blank"><?php esc_html_e( 'Upgrade to PRO', 'wc-serial-numbers' ); ?></a>
<a href="https://pluginever.com/plugins/woocommerce-serial-numbers-pro/?utm_source=plugin-settings&utm_medium=banner&utm_campaign=upgrade&utm_id=wc-serial-numbers" class="button" style="color:white;" target="_blank"><?php esc_html_e( 'Upgrade to PRO', 'wc-serial-numbers' ); ?></a>
</div>
<?php
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading