/** * Create a new 'stub' payment token * * @since 2.6 * @param string $extra A string to insert and get to test the metadata functionality of a token * @return WC_Payment_Token_Stub object */ public static function create_stub_token($extra) { $token = new WC_Payment_Token_Stub(); $token->set_extra($extra); $token->set_token(time()); $token->save(); return $token; }
/** * Test: get_payment_tokens */ function test_get_payment_tokens() { $object = new WC_Order(); $object->save(); $token = new WC_Payment_Token_Stub(); $token->set_extra(__FUNCTION__); $token->set_token(time()); $token->save(); $object->add_payment_token($token); $this->assertCount(1, $object->get_payment_tokens()); }
/** * Test creating a new token. * @since 2.6.0 */ public function test_wc_payment_token_create() { $token = new WC_Payment_Token_Stub(); $token->set_extra(__FUNCTION__); $token->set_token(time()); $token->save(); $this->assertNotEmpty($token->get_id()); $token = new WC_Payment_Token_Stub($token->get_id()); $this->assertEquals(__FUNCTION__, $token->get_extra()); }