Skip to content

Commit

Permalink
updated test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
erikyo committed Oct 13, 2023
1 parent 04f1973 commit a75ca21
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"phpunit/phpunit": "^9.6.13",
"wp-phpunit/wp-phpunit": "^5.9.5",
"yoast/phpunit-polyfills": "^1.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7"
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"ext-dom": "*",
"ext-libxml": "*"
},
"require": {
"geoip2/geoip2": "~2.0",
Expand Down
7 changes: 4 additions & 3 deletions core/CF7_AntiSpam_Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public function __construct( $plugin_name, $version ) {
public function cf7a_honeypot_add( $form_elements ) {
/* A list of default names for the honeypot fields. */
$options = get_option( 'cf7a_options', array() );
$input_names = get_honeypot_input_names( $options['honeypot_input_names'] );
$input_class = sanitize_html_class( $this->options['cf7a_customizations_class'] );
$input_names = !empty( $options['honeypot_input_names'] ) ? get_honeypot_input_names( $options['honeypot_input_names'] ) : array();
$input_class = !empty( $this->options['cf7a_customizations_class'] ) ? sanitize_html_class( $this->options['cf7a_customizations_class'] ) : 'cf7a';
/**
* Controls the maximum number of honeypots.
*
Expand All @@ -91,7 +91,8 @@ public function cf7a_honeypot_add( $form_elements ) {
/* add honeypot fields */
foreach ( $inputs as $i => $input ) {
if ( stripos( $input, 'type="text"' ) !== false ) {
$honeypot_names = $input_names[ $i ];
// TODO: add set of default values
$honeypot_names = isset( $input_names[ $i ] ) ? $input_names[ $i ] : 'hey_' . $i;
$honeypot_input = sprintf(
'<input type="text" name="%1$s" value="" autocomplete="fill" class="%2$s" tabindex="-1" />',
esc_attr( $honeypot_names ),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"preplugin-zip": "wp-env run composer \"composer install --no-dev\"",
"plugin-zip": "wp-scripts plugin-zip",
"postplugin-zip": "wp-env run composer \"composer install\"",
"lint:css": "wp-scripts lint-style ./admin/src/**/*.scss --fix",
"lint:js": "wp-scripts lint-js ./includes/src ./admin/src",
"lint:css": "wp-scripts lint-style ./src/**/*.scss --fix",
"lint:js": "wp-scripts lint-js ./src/**/*.js",
"packages-update": "wp-scripts packages-update",
"wp-env:start": "wp-env start",
"wp-env:stop": "wp-env stop",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace CF7_AntiSpam\Tests\PhpUnit\Tests;

use PHPUnit\Framework\TestCase;

class CF7_AntiSpam_ActivatorTest extends TestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace CF7_AntiSpam\Tests;
namespace CF7_AntiSpam\Tests\PhpUnit\Tests;

use CF7_AntiSpam\Core\CF7_AntiSpam_Filters;
use PHPUnit\Framework\TestCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

namespace CF7_AntiSpam\Tests\PhpUnit\Tests;

use CF7_AntiSpam\Core\CF7_AntiSpam;
use CF7_AntiSpam\Core\CF7_AntiSpam_Frontend;
use DOMDocument;
use PHPUnit\Framework\TestCase;

/**
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/bootstrap.php → tests/PhpUnit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
*
* @package Cf7_Antispam
*/

// Debug settings for parity with WordPress Core's PHPUnit tests.
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', true );
}
if ( ! defined( 'LOCAL_WP_DEBUG_LOG' ) ) {
define( 'LOCAL_WP_DEBUG_LOG', true );
}
Expand All @@ -21,8 +19,6 @@
define( 'LOCAL_WP_ENVIRONMENT_TYPE', 'local' );
}

include("vendor/autoload.php");

$_tests_dir = getenv( 'WP_TESTS_DIR' );

if ( ! $_tests_dir ) {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a75ca21

Please sign in to comment.