Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Jun 23, 2023
1 parent 1b3608d commit 19a38d3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
* @coversDefaultClass Ginger_MO_Translation_Compat_Provider
*/
class Ginger_MO_Translation_Compat_Provider_Tests extends WP_UnitTestCase {
public function tear_down() {
if ( file_exists( DIR_TESTDATA . '/pomo/simple.php' ) ) {
$this->unlink( DIR_TESTDATA . '/pomo/simple.php' );
}

if ( file_exists( DIR_TESTDATA . '/pomo/plural.php' ) ) {
$this->unlink( DIR_TESTDATA . '/pomo/plural.php' );
}
}
/**
* @covers ::__get
* @covers ::make_entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
* @coversDefaultClass Ginger_MO_Translation_Compat
*/
class Ginger_MO_Translation_Compat_Tests extends WP_UnitTestCase {
public function tear_down() {
if ( file_exists( DIR_TESTDATA . '/pomo/simple.php' ) ) {
$this->unlink( DIR_TESTDATA . '/pomo/simple.php' );
}
}

/**
* @covers ::overwrite_wordpress
*/
Expand Down Expand Up @@ -59,6 +65,29 @@ public function test_load_textdomain() {
);
}


/**
* @covers ::load_textdomain
*/
public function test_load_textdomain_creates_and_reads_php_files() {
$load_mo_successful = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );

$unload_mo_successful = unload_textdomain( 'wp-tests-domain' );

$file_exists = file_exists( DIR_TESTDATA . '/pomo/simple.php' );

$load_php_successful = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.php' );

$unload_php_successful = unload_textdomain( 'wp-tests-domain' );

$this->assertTrue( $load_mo_successful, 'MO file not successfully loaded' );
$this->assertTrue( $unload_mo_successful );
$this->assertTrue( $file_exists );
$this->assertTrue( $load_php_successful, 'PHP file not successfully loaded' );
$this->assertTrue( $unload_php_successful );
}


/**
* @covers ::unload_textdomain
*/
Expand Down

0 comments on commit 19a38d3

Please sign in to comment.