• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wp-graphql / wp-graphql-woocommerce / 23675172456

28 Mar 2026 02:10AM UTC coverage: 70.983% (-18.4%) from 89.424%
23675172456

Pull #1003

github

web-flow
Merge 05339093d into 6fb7b226f
Pull Request #1003: devops: WC email template tests, COT cursor HPOS fix, checkout account auth

71 of 81 new or added lines in 5 files covered. (87.65%)

3346 existing lines in 124 files now uncovered.

12576 of 17717 relevant lines covered (70.98%)

55.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.89
/includes/type/interface/class-payment-token-interface.php
1
<?php
2
/**
3
 * WPInterface Type - Payment_Token_Interface
4
 *
5
 * @package WPGraphQL\WooCommerce\Type\WPInterface
6
 * @since   0.10.1
7
 */
8

9
namespace WPGraphQL\WooCommerce\Type\WPInterface;
10

11
use GraphQLRelay\Relay;
12

13
/**
14
 * Class Payment_Token_Interface
15
 */
16
class Payment_Token_Interface {
17
        /**
18
         * Registers the "PaymentToken" interface.
19
         *
20
         * @return void
21
         */
22
        public static function register_interface() {
23
                register_graphql_interface_type(
110✔
24
                        'PaymentTokenInterface',
110✔
25
                        [
110✔
26
                                'description' => __( 'Payment token object', 'wp-graphql-woocommerce' ),
110✔
27
                                'interfaces'  => [ 'Node' ],
110✔
28
                                'fields'      => self::get_fields(),
110✔
29
                                'resolveType' => static function ( $value ) {
110✔
30
                                        $type_registry = \WPGraphQL::get_type_registry();
1✔
31
                                        $type          = $value->get_type();
1✔
32
                                        switch ( $type ) {
33
                                                case 'CC':
1✔
34
                                                        return $type_registry->get_type( 'PaymentTokenCC' );
1✔
35
                                                case 'eCheck':
1✔
36
                                                        return $type_registry->get_type( 'PaymentTokenECheck' );
1✔
37
                                                default:
38
                                                        return $type_registry->get_type( 'PaymentToken' );
×
39
                                        }
40
                                },
110✔
41
                        ]
110✔
42
                );
110✔
43
        }
44

45
        /**
46
         * Return field definitions.
47
         *
48
         * @param array $other_fields  Optional fields to be added.
49
         * @return array
50
         */
51
        public static function get_fields( $other_fields = [] ) {
52
                return array_merge(
110✔
53
                        [
110✔
54
                                'id'        => [
110✔
55
                                        'type'        => [ 'non_null' => 'ID' ],
110✔
56
                                        'description' => __( 'Token ID unique identifier', 'wp-graphql-woocommerce' ),
110✔
57
                                        'resolve'     => static function ( $source ) {
110✔
58
                                                return ! empty( $source->get_id() ) ? Relay::toGlobalId( 'token', $source->get_id() ) : null;
1✔
59
                                        },
110✔
60
                                ],
110✔
61
                                'tokenId'   => [
110✔
62
                                        'type'        => [ 'non_null' => 'Integer' ],
110✔
63
                                        'description' => __( 'Token database ID.', 'wp-graphql-woocommerce' ),
110✔
64
                                        'resolve'     => static function ( $source ) {
110✔
65
                                                return ! empty( $source->get_id() ) ? $source->get_id() : null;
1✔
66
                                        },
110✔
67
                                ],
110✔
68
                                'type'      => [
110✔
69
                                        'type'        => [ 'non_null' => 'String' ],
110✔
70
                                        'description' => __( 'Token type', 'wp-graphql-woocommerce' ),
110✔
71
                                        'resolve'     => static function ( $source ) {
110✔
UNCOV
72
                                                return ! empty( $source->get_type() ) ? $source->get_type() : null;
×
73
                                        },
110✔
74
                                ],
110✔
75
                                'gateway'   => [
110✔
76
                                        'type'        => 'PaymentGateway',
110✔
77
                                        'description' => __( 'Token payment gateway', 'wp-graphql-woocommerce' ),
110✔
78
                                        'resolve'     => static function ( $source ) {
110✔
79
                                                $gateways   = \WC()->payment_gateways()->payment_gateways();
×
80
                                                $gateway_id = $source->get_gateway_id();
×
81
                                                if ( isset( $gateways[ $gateway_id ] ) ) {
×
82
                                                        return $gateways[ $gateway_id ];
×
83
                                                }
84

85
                                                return null;
×
86
                                        },
110✔
87
                                ],
110✔
88
                                'isDefault' => [
110✔
89
                                        'type'        => 'Boolean',
110✔
90
                                        'description' => __( 'Is token connected to user\'s preferred payment method', 'wp-graphql-woocommerce' ),
110✔
91
                                        'resolve'     => static function ( $source ) {
110✔
UNCOV
92
                                                return ! is_null( $source->is_default() ) ? $source->is_default() : false;
×
93
                                        },
110✔
94
                                ],
110✔
95
                        ],
110✔
96
                        $other_fields
110✔
97
                );
110✔
98
        }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc