/** * 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->create(); $object->add_payment_token($token); $this->assertCount(1, $object->get_payment_tokens()); }
/** * Test legacy token functions. * * @since 2.7.0 * * @expectedDeprecated WC_Payment_Token::read * @expectedDeprecated WC_Payment_Token::create * @expectedDeprecated WC_Payment_Token::update */ public function test_wc_payment_token_legacy() { $token = WC_Helper_Payment_Token::create_stub_token(__FUNCTION__); $token_id = $token->get_id(); $token_read = new WC_Payment_Token_Stub(); $token_read->read($token_id); $this->assertEquals($token_id, $token_read->get_id()); $token = new WC_Payment_Token_Stub(); $token->set_token('blah'); $token->create(); $this->assertEquals('blah', $token->get_token()); $this->assertNotEmpty($token->get_id()); $token->set_token('blah2'); $token->update(); $this->assertEquals('blah2', $token->get_token()); }
/** * 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->create(); $this->assertNotEmpty($token->get_id()); $this->assertEquals(__FUNCTION__, $token->get_extra()); }