Skip to content

Commit

Permalink
tests: lint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Apr 7, 2024
1 parent 154863d commit a68585e
Show file tree
Hide file tree
Showing 91 changed files with 1,146 additions and 1,337 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
- chore: Lock WPBrowser to <3.5.0 to prevent conflicts with Codeception.
- chore: Implement strict PHPStan rules and fix resulting issues.
- chore: Add traversable type hints throughout the codebase.
- tests: Lint tests.
- ci: Update GitHub Actions to latest versions.
- ci: Test plugin compatibility with WordPress 6.5.0.
- ci: Test plugin compatibility with PHP 8.2.
Expand Down
16 changes: 8 additions & 8 deletions tests/_support/AcceptanceTester.php
Expand Up @@ -3,6 +3,7 @@

/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
Expand All @@ -14,13 +15,12 @@
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
* @SuppressWarnings(\PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor {
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
/**
* Define custom actions here
*/
}
7 changes: 3 additions & 4 deletions tests/_support/Factory/DraftEntry.php
Expand Up @@ -14,14 +14,14 @@
* Class - Entry
*/
class DraftEntry extends \WP_UnitTest_Factory_For_Thing {

/**
* Constructor
*
* @param object $factory .
*/
public function __construct( $factory = null ) {
parent::__construct( $factory );

$this->default_generation_definitions = [
'source_url' => '',
'page_number' => 1,
Expand All @@ -34,7 +34,7 @@ public function __construct( $factory = null ) {
*
* @param array $args entry arguments.
*/
public function create_object( $args ) : string {
public function create_object( $args ): string {
$form = GFAPI::get_form( $args['form_id'] );

$entry = array_replace(
Expand Down Expand Up @@ -101,9 +101,8 @@ public function update_object( $resume_token, $properties ) {
* Gets the draft entry from an object id.
*
* @param string $resume_token .
* @return array
*/
public function get_object_by_id( $resume_token ) : array {
public function get_object_by_id( $resume_token ): array {
return GFFormsModel::get_draft_submission_values( $resume_token );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/_support/Factory/Entry.php
Expand Up @@ -15,14 +15,14 @@
* Class - Entry
*/
class Entry extends \WP_UnitTest_Factory_For_Thing {

/**
* Constructor
*
* @param object $factory .
*/
public function __construct( $factory = null ) {
parent::__construct( $factory );

$this->default_generation_definitions = [
'id' => new WP_UnitTest_Generator_Sequence( '%s' ),
'currency' => 'USD',
Expand All @@ -34,7 +34,7 @@ public function __construct( $factory = null ) {
*
* @param array $args entry arguments.
*/
public function create_object( $args ) : int {
public function create_object( $args ): int {
return GFAPI::add_entry( $args );
}

Expand Down
9 changes: 4 additions & 5 deletions tests/_support/Factory/Field.php
Expand Up @@ -7,22 +7,21 @@

namespace Tests\WPGraphQL\GF\Factory;

use GF_Field;
use GF_Fields;
use WP_UnitTest_Generator_Sequence;

/**
* Class - Field
*/
class Field extends \WP_UnitTest_Factory_For_Thing {

/**
* Constructor
*
* @param object $factory .
*/
public function __construct( $factory = null ) {
parent::__construct( $factory );

$this->default_generation_definitions = [
'id' => new WP_UnitTest_Generator_Sequence( '%s' ),
'label' => new WP_UnitTest_Generator_Sequence( 'Field label %s' ),
Expand Down Expand Up @@ -58,8 +57,8 @@ public function create_many( $count, $args = [], $generation_definitions = null
/**
* Updates a field object.
*
* @param GF_Field $field .
* @param array $args properties to update.
* @param \GF_Field $field .
* @param array $args properties to update.
*/
public function update_object( $field, $args ) {
foreach ( $args as $key => $value ) {
Expand All @@ -71,7 +70,7 @@ public function update_object( $field, $args ) {
/**
* Get the field object. Returns itself.
*
* @param GF_Field $field .
* @param \GF_Field $field .
*/
public function get_object_by_id( $field ) {
return $field;
Expand Down
1 change: 1 addition & 0 deletions tests/_support/Factory/Form.php
Expand Up @@ -22,6 +22,7 @@ class Form extends \WP_UnitTest_Factory_For_Thing {
*/
public function __construct( $factory = null ) {
parent::__construct( $factory );

$this->default_generation_definitions = [
'title' => new WP_UnitTest_Generator_Sequence( 'Form title %s' ),
'description' => new WP_UnitTest_Generator_Sequence( 'Form description %s' ),
Expand Down
2 changes: 0 additions & 2 deletions tests/_support/Helper/Acceptance.php
Expand Up @@ -5,6 +5,4 @@
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module {


}
2 changes: 0 additions & 2 deletions tests/_support/Helper/Functional.php
Expand Up @@ -5,6 +5,4 @@
// all public methods declared in helper class will be available in $I

class Functional extends \Codeception\Module {


}
333 changes: 165 additions & 168 deletions tests/_support/Helper/GFHelpers/ExpectedFormFields.php

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions tests/_support/Helper/GFHelpers/GFHelpers.php
Expand Up @@ -16,7 +16,7 @@ abstract class GFHelpers {
/**
* Provides access to dummy functions.
*
* @var Dummy
* @var \Dummy
*/
public $dummy;

Expand All @@ -26,14 +26,14 @@ abstract class GFHelpers {
* @var array
*/
public $keys;

/**
* The generated list of values.
*
* @var array
*/
public $values;


/**
* Constructor
*
Expand All @@ -49,8 +49,6 @@ public function __construct( array $keys ) {

/**
* Flattens key => value pairs to grab all the keys.
*
* @param array $keys
*/
public function get_keys( array $keys ) {
$return_values = [];
Expand All @@ -68,7 +66,6 @@ public function get_keys( array $keys ) {
/**
* Gets the key => value pair for the given key name.
*
* @param string $key
* @param [type] $value
*/
public function get( string $key, $value = null ) {
Expand All @@ -77,8 +74,6 @@ public function get( string $key, $value = null ) {

/**
* Gets all key => value pairs for the defined keys.
*
* @param array $keys
*/
public function getAll( array $keys ) {
$return_values = [];
Expand Down

0 comments on commit a68585e

Please sign in to comment.