Skip to content

Commit

Permalink
Test get_plugin_slug()
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-mendonca committed Jul 11, 2024
1 parent d30db65 commit 5a17839
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/phpunit/includes/test-translations-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
class Test_Translations_API extends WP_UnitTestCase {


/**
* Test get plugin slug from its file path.
*/
public function test_get_plugin_slug() {

// Given a complete file path with folder and file.
$plugin_slug = Translations_API::get_plugin_slug( 'translation-stats/translation-stats.php' );

$this->assertEquals( $plugin_slug, 'translation-stats' );

// Given just the file name and extension.
$plugin_slug = Translations_API::get_plugin_slug( 'translation-stats.php' );

$this->assertEquals( $plugin_slug, 'translation-stats' );

// Given just a slug.
$plugin_slug = Translations_API::get_plugin_slug( 'Translation Stats' );

$this->assertEquals( $plugin_slug, 'translation-stats' );

$plugin_slug = Translations_API::get_plugin_slug( 'translation-stats' );

$this->assertEquals( $plugin_slug, 'translation-stats' );

}


/**
* Test get plugin data from translate.WordPress.org API.
*/
Expand Down

0 comments on commit 5a17839

Please sign in to comment.