Added tests for path tokenization/untokenization

This commit is contained in:
Christopher Allford 2020-04-05 12:15:39 -07:00
parent e270dfce2e
commit 4aab99614a
1 changed files with 66 additions and 0 deletions

View File

@ -569,6 +569,72 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
$this->assertEmpty( wc_get_template_part( 'nothinghere' ) );
}
/**
* Tests the wc_tokenize_path function.
*/
public function test_wc_tokenize_path() {
$path = wc_tokenize_path( ABSPATH . '/test', array() );
$this->assertEquals( ABSPATH . '/test', $path );
$path = wc_tokenize_path(
ABSPATH . '/test',
array(
'ABSPATH' => ABSPATH,
)
);
$this->assertEquals( '{{ABSPATH}}/test', $path );
$path = wc_tokenize_path(
ABSPATH . '/test',
array(
'WP_CONTENT_DIR' => WP_CONTENT_DIR,
)
);
$this->assertEquals( ABSPATH . '/test', $path );
$path = wc_tokenize_path(
WP_CONTENT_DIR . '/test',
array(
'WP_CONTENT_DIR' => WP_CONTENT_DIR,
'ABSPATH' => ABSPATH,
)
);
$this->assertEquals( '{{WP_CONTENT_DIR}}/test', $path );
}
/**
* Tests the wc_untokenize_path function.
*/
public function test_wc_untokenize_path() {
$path = wc_untokenize_path( '{{ABSPATH}}/test', array() );
$this->assertEquals( '{{ABSPATH}}/test', $path );
$path = wc_untokenize_path(
'{{ABSPATH}}/test',
array(
'ABSPATH' => ABSPATH,
)
);
$this->assertEquals( ABSPATH . '/test', $path );
$path = wc_untokenize_path(
'{{ABSPATH}}/test',
array(
'WP_CONTENT_DIR' => WP_CONTENT_DIR,
)
);
$this->assertEquals( '{{ABSPATH}}/test', $path );
$path = wc_untokenize_path(
'{{WP_CONTENT_DIR}}/test',
array(
'WP_CONTENT_DIR' => WP_CONTENT_DIR,
'ABSPATH' => ABSPATH,
)
);
$this->assertEquals( WP_CONTENT_DIR . '/test', $path );
}
/**
* Test wc_get_template.
*