mirror of
https://gh.wpcy.net/https://github.com/SilverAssist/wp-github-updater.git
synced 2026-04-27 08:24:27 +08:00
- Update composer.json to require PHP >=8.2 - Update all documentation (README.md, copilot-instructions.md) - Update GitHub Actions workflow (create-release.yml) - Update source code default value in UpdaterConfig.php - Update all test fixtures and test expectations - All 51 tests passing successfully
69 lines
2.6 KiB
PHP
69 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace SilverAssist\WpGithubUpdater\Tests\Unit;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use SilverAssist\WpGithubUpdater\UpdaterConfig;
|
|
|
|
class UpdaterConfigTest extends TestCase
|
|
{
|
|
private static string $testPluginFile;
|
|
|
|
public static function setUpBeforeClass(): void
|
|
{
|
|
self::$testPluginFile = dirname(__DIR__) . "/fixtures/test-plugin.php";
|
|
}
|
|
|
|
public function testBasicConfiguration(): void
|
|
{
|
|
$config = new UpdaterConfig(self::$testPluginFile, "owner/repo");
|
|
|
|
$this->assertEquals(self::$testPluginFile, $config->pluginFile);
|
|
$this->assertEquals("owner/repo", $config->githubRepo);
|
|
$this->assertEquals("6.0", $config->requiresWordPress);
|
|
$this->assertEquals("8.2", $config->requiresPHP);
|
|
$this->assertEquals("{slug}-v{version}.zip", $config->assetPattern);
|
|
$this->assertEquals("wp-github-updater", $config->textDomain);
|
|
}
|
|
|
|
public function testCustomConfiguration(): void
|
|
{
|
|
$options = [
|
|
"plugin_name" => "Test Plugin",
|
|
"plugin_description" => "A test plugin",
|
|
"plugin_author" => "Test Author",
|
|
"requires_wordpress" => "6.2",
|
|
"requires_php" => "8.1",
|
|
"asset_pattern" => "custom-{version}.zip",
|
|
"cache_duration" => 3600,
|
|
"ajax_action" => "custom_check",
|
|
"ajax_nonce" => "custom_nonce",
|
|
"text_domain" => "my-custom-plugin"
|
|
];
|
|
|
|
$config = new UpdaterConfig(self::$testPluginFile, "owner/repo", $options);
|
|
|
|
$this->assertEquals("Test Plugin", $config->pluginName);
|
|
$this->assertEquals("A test plugin", $config->pluginDescription);
|
|
$this->assertEquals("Test Author", $config->pluginAuthor);
|
|
$this->assertEquals("6.2", $config->requiresWordPress);
|
|
$this->assertEquals("8.1", $config->requiresPHP);
|
|
$this->assertEquals("custom-{version}.zip", $config->assetPattern);
|
|
$this->assertEquals(3600, $config->cacheDuration);
|
|
$this->assertEquals("custom_check", $config->ajaxAction);
|
|
$this->assertEquals("custom_nonce", $config->ajaxNonce);
|
|
$this->assertEquals("my-custom-plugin", $config->textDomain);
|
|
}
|
|
|
|
public function testTranslationMethods(): void
|
|
{
|
|
$config = new UpdaterConfig(self::$testPluginFile, "owner/repo", [
|
|
"text_domain" => "test-domain"
|
|
]);
|
|
|
|
// These methods would normally call WordPress i18n functions
|
|
// We"re just testing they exist and return strings for now
|
|
$this->assertIsString($config->__("Test string"));
|
|
$this->assertIsString($config->esc_html__("Test string"));
|
|
}
|
|
}
|