From 5a8cfc47fda60a14211b007ac40f4f73ec05a5fb Mon Sep 17 00:00:00 2001 From: Chris Carlevato Date: Wed, 1 Apr 2020 20:51:02 -0700 Subject: [PATCH] Add tests --- _test/tests/test-shorten-rebrandly.php | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/_test/tests/test-shorten-rebrandly.php b/_test/tests/test-shorten-rebrandly.php index f7fbe81..71b4505 100644 --- a/_test/tests/test-shorten-rebrandly.php +++ b/_test/tests/test-shorten-rebrandly.php @@ -111,4 +111,32 @@ function test_rebrandly_request_no_link() { $this->assertTrue( strpos( $shortener->get_response(), 'https://rebrand.ly/' ) === false ); } + /** + * Test rebrandly domains update checkbox reset + * + * @depends test_is_test + */ + function test_rebrandly_domains_update_checkbox() { + $plugin = new UtmDotCodes(); + $value = $plugin->pre_rebrandly_domains_update('new value', 'old value', UtmDotCodes::POST_TYPE . '_rebrandly_domains_update'); + + $this->assertEquals( '', $value ); + } + + /** + * Test rebrandly domain retrieval + * + * @depends test_is_test + */ + function test_rebrandly_domains_update_options() { + $plugin = new UtmDotCodes(); + update_option( UtmDotCodes::POST_TYPE . '_shortener', 'rebrandly' ); + update_option( UtmDotCodes::POST_TYPE . '_apikey', getenv( 'UTMDC_REBRANDLY_API' ) ); + + $value = $plugin->pre_rebrandly_domains_update('on', '', UtmDotCodes::POST_TYPE . '_rebrandly_domains_update'); + $domains = json_decode( get_option( UtmDotCodes::POST_TYPE . '_rebrandly_domains' ) ); + + $this->assertGreaterThan( 0, count($domains) ); + $this->assertEquals( '', $value ); + } }