Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Carlevato committed Apr 2, 2020
1 parent a4ee115 commit 5a8cfc4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions _test/tests/test-shorten-rebrandly.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

0 comments on commit 5a8cfc4

Please sign in to comment.