Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
swissspidy committed May 8, 2023
commit 96e6a9633f1cf5913e8594319962d21078616ee0
11 changes: 8 additions & 3 deletions features/makephp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,22 @@ Feature: Generate PHP files from PO files
Success: Created 1 file.
"""
And the return code should be 0
And STDERR should be empty
And the foo-plugin/foo-plugin-de_DE.php file should contain:
"""
'language'=>'de_DE',
'language'=>'de_DE'
"""
And the foo-plugin/foo-plugin-de_DE.php file should contain:
"""
'domain'=>'foo-plugin'
"""
And the foo-plugin/foo-plugin-de_DE.php file should contain:
"""
'plural-forms'=>'nplurals=2; plural=(n != 1)'
'plural-forms'=>'nplurals=2; plural=(n != 1);'
"""
And the foo-plugin/foo-plugin-de_DE.php file should contain:
"""
'messages'=>[''=>['Foo Plugin'=>[0=>'Foo Plugin']]]
"""

Scenario: Does include translations
Expand Down Expand Up @@ -158,5 +163,5 @@ Feature: Generate PHP files from PO files
And the return code should be 0
And the foo-plugin/foo-plugin-de_DE.php file should contain:
"""
Bar Plugin
'messages'=>[''=>['Foo Plugin'=>[0=>'Bar Plugin']]]
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a test that verifies a valid PHP translation file is produced?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid as in syntax or as in translation gets loaded properly in WordPress?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the latter but we could check both, I suppose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably best done in a future PR because we don't have similar assertions for the other file formats, and the PHP format especially is not yet merged into core.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

2 changes: 1 addition & 1 deletion src/PhpArrayGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function toString( Translations $translations, array $options = []
continue;
}

$array[ $headers[ $name] ] = $value;
$array[ $headers[ $name ] ] = $value;
}

return '<?php' . PHP_EOL . 'return ' . static::var_export( $array, true ) . ';';
Expand Down