• 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

0.0
/includes/model/class-shipping-method.php
1
<?php
2
/**
3
 * Model - Shipping_Method
4
 *
5
 * Resolves shipping method object model
6
 *
7
 * @package WPGraphQL\WooCommerce\Model
8
 * @since 0.0.2
9
 */
10

11
namespace WPGraphQL\WooCommerce\Model;
12

13
use GraphQLRelay\Relay;
14
use WPGraphQL\Model\Model;
15

16
/**
17
 * Class Shipping_Method
18
 *
19
 * @property \WC_Shipping_Method $data
20
 *
21
 * @property int    $ID
22
 * @property string $id
23
 * @property int    $databaseId
24
 * @property string $title
25
 * @property string $description
26
 *
27
 * @package WPGraphQL\WooCommerce\Model
28
 */
29
class Shipping_Method extends Model {
30
        /**
31
         * Shipping_Method constructor
32
         *
33
         * @param \WC_Shipping_Method $method - Shipping method object.
34
         */
35
        public function __construct( $method ) {
UNCOV
36
                $this->data                = $method;
×
UNCOV
37
                $allowed_restricted_fields = [
×
UNCOV
38
                        'isRestricted',
×
UNCOV
39
                        'isPrivate',
×
UNCOV
40
                        'isPublic',
×
UNCOV
41
                        'id',
×
UNCOV
42
                        'databaseId',
×
UNCOV
43
                ];
×
44

45
                // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
UNCOV
46
                $restricted_cap = apply_filters( 'shipping_method_restricted_cap', '' );
×
47

UNCOV
48
                parent::__construct( $restricted_cap, $allowed_restricted_fields, null );
×
49
        }
50

51
        /**
52
         * Determines if the order item should be considered private.
53
         *
54
         * @return bool
55
         */
56
        protected function is_private() {
UNCOV
57
                return false;
×
58
        }
59

60
        /**
61
         * Initializes the Order field resolvers.
62
         */
63
        protected function init() {
UNCOV
64
                if ( empty( $this->fields ) ) {
×
UNCOV
65
                        $this->fields = [
×
UNCOV
66
                                'ID'          => function () {
×
UNCOV
67
                                        return $this->data->id;
×
UNCOV
68
                                },
×
UNCOV
69
                                'id'          => function () {
×
UNCOV
70
                                        return ! empty( $this->data->id ) ? Relay::toGlobalId( 'shipping_method', $this->data->id ) : null;
×
UNCOV
71
                                },
×
UNCOV
72
                                'databaseId'  => function () {
×
UNCOV
73
                                        return ! empty( $this->ID ) ? $this->ID : null;
×
UNCOV
74
                                },
×
UNCOV
75
                                'title'       => function () {
×
UNCOV
76
                                        return ! empty( $this->data->method_title ) ? $this->data->method_title : null;
×
UNCOV
77
                                },
×
UNCOV
78
                                'description' => function () {
×
UNCOV
79
                                        return ! empty( $this->data->method_description ) ? $this->data->method_description : null;
×
UNCOV
80
                                },
×
UNCOV
81
                        ];
×
82
                }
83
        }
84

85
        /**
86
         * Forwards function calls to WC_Data sub-class instance.
87
         *
88
         * @param string $method - function name.
89
         * @param array  $args  - function call arguments.
90
         *
91
         * @return mixed
92
         *
93
         * @throws \BadMethodCallException Method not found on WC data object.
94
         */
95
        public function __call( $method, $args ) {
96
                if ( \is_callable( [ $this->data, $method ] ) ) {
×
97
                        return $this->data->$method( ...$args );
×
98
                }
99

100
                $class = self::class;
×
101
                throw new \BadMethodCallException( "Call to undefined method {$method} on the {$class}" );
×
102
        }
103

104
        /**
105
         * Returns the source WC_Data instance
106
         *
107
         * @return \WC_Shipping_Method
108
         */
109
        public function as_WC_Data() {
UNCOV
110
                return $this->data;
×
111
        }
112
}
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