@@ -201,7 +201,6 @@ private function updateCustomer( $input ) {
201201 return $ actual ;
202202 }
203203
204- // tests
205204 public function testRegisterMutationWithoutCustomerInfo () {
206205 /**
207206 * Assertion One
@@ -518,4 +517,50 @@ public function testUpdateMutationWithShippingSameAsBilling() {
518517
519518 $ this ->assertEquals ( $ expected , $ actual );
520519 }
520+
521+ public function testRegisterMutationWithoutAnyInfo () {
522+ /**
523+ * Assertion One
524+ *
525+ * Tests mutation without a providing an username and password.
526+ */
527+ $ actual = $ this ->registerCustomer (
528+ array (
529+ 'clientMutationId ' => 'someId ' ,
530+ 'email ' => $ this ->email ,
531+ 'firstName ' => $ this ->first_name ,
532+ 'lastName ' => $ this ->last_name ,
533+ )
534+ );
535+
536+ // use --debug flag to view.
537+ codecept_debug ( $ actual );
538+
539+ $ user =
get_user_by (
'email ' ,
'[email protected] ' );
540+ $ this ->assertTrue ( is_a ( $ user , WP_User::class ) );
541+
542+ $ expected = array (
543+ 'data ' => array (
544+ 'registerCustomer ' => array (
545+ 'clientMutationId ' => 'someId ' ,
546+ 'authToken ' => \WPGraphQL \JWT_Authentication \Auth::get_token ( $ user ),
547+ 'refreshToken ' => \WPGraphQL \JWT_Authentication \Auth::get_refresh_token ( $ user ),
548+ 'customer ' => array (
549+ 'databaseId ' => $ user ->ID ,
550+ 'email ' => $ this ->email ,
551+ 'username ' => $ user ->user_login ,
552+ 'firstName ' => $ this ->first_name ,
553+ 'lastName ' => $ this ->last_name ,
554+ 'billing ' => $ this ->empty_billing (),
555+ 'shipping ' => $ this ->empty_shipping (),
556+ ),
557+ 'viewer ' => array (
558+ 'userId ' => $ user ->ID ,
559+ )
560+ ),
561+ ),
562+ );
563+
564+ $ this ->assertEquals ( $ expected , $ actual );
565+ }
521566}
0 commit comments