-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add destination file support to MakePoCommand
- Loading branch information
sdnunca
committed
Nov 16, 2023
1 parent
e84691f
commit dc14056
Showing
3 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace WP_CLI\I18n\Tests; | ||
|
||
use Gettext\Translation; | ||
use WP_CLI\I18n\PotGenerator; | ||
use Gettext\Translations; | ||
use WP_CLI\Tests\TestCase; | ||
use WP_CLI\I18n\MakeMoCommand; | ||
use WP_CLI\Utils; | ||
|
||
class MakeMoTest extends TestCase { | ||
public function set_up() { | ||
parent::set_up(); | ||
$this->temp_dir = Utils\get_temp_dir() . uniqid( 'wp-cli-test-make-po-', true ) . '/'; | ||
mkdir( $this->temp_dir ); | ||
} | ||
|
||
public function tear_down() { | ||
rmdir( $this->temp_dir ); | ||
|
||
parent::tear_down(); | ||
} | ||
|
||
/** | ||
* Test wp i18n make-mo foo.po | ||
*/ | ||
public function test_single_file_generation() { | ||
$file_path = $this->temp_dir . '/test.po'; | ||
touch( $file_path ); | ||
$make_mo = new MakeMoCommand(); | ||
$make_mo( array( | ||
$file_path, | ||
), array() ); | ||
$this->assertTrue( is_file( $this->temp_dir . '/test.mo' ), 'MO file not generated' ); | ||
unlink( $file_path ); | ||
unlink( $this->temp_dir . '/test.mo' ); | ||
} | ||
|
||
/** | ||
* Test wp i18n make-mo foo.po bar.mo | ||
*/ | ||
public function test_single_file_generation_named() { | ||
$file_path = $this->temp_dir . '/test.po'; | ||
$mo_file_path = $this->temp_dir . '/bar.mo'; | ||
touch( $file_path ); | ||
$make_mo = new MakeMoCommand(); | ||
$make_mo( array( | ||
$file_path, | ||
$mo_file_path, | ||
), array() ); | ||
$this->assertTrue( is_file( $mo_file_path ), 'MO file not generated' ); | ||
unlink( $file_path ); | ||
unlink( $mo_file_path ); | ||
} | ||
|
||
/** | ||
* Test wp i18n make-mo foo/ | ||
*/ | ||
public function test_whole_directory_generation() { | ||
$base_directory = $this->temp_dir . '/foo'; | ||
mkdir( $base_directory, 0777, true ); | ||
$file_path = $base_directory . '/test.po'; | ||
touch( $file_path ); | ||
$make_mo = new MakeMoCommand(); | ||
$make_mo( array( | ||
$base_directory, | ||
), array() ); | ||
$this->assertTrue( is_file( $base_directory . '/test.mo' ), 'MO file not generated' ); | ||
unlink( $file_path ); | ||
unlink( $base_directory . '/test.mo' ); | ||
rmdir( $base_directory ); | ||
} | ||
} |