Surface Gitea settings via projects_portfolio_settings() and test

This commit is contained in:
Keith Solomon
2026-08-09 23:12:37 -05:00
parent 925ef184b9
commit e60a9eafb3
2 changed files with 36 additions and 2 deletions
+4 -2
View File
@@ -16,8 +16,10 @@ function projects_portfolio_settings() {
if ( $settings === null ) {
$settings = [
'github_api_token' => get_option( 'projects_portfolio_github_api_token', '' ),
'share_telemetry' => get_option( 'projects_portfolio_share_telemetry', '0' ),
'github_api_token' => get_option( 'projects_portfolio_github_api_token', '' ),
'gitea_api_token' => get_option( 'projects_portfolio_gitea_api_token', '' ),
'default_gitea_base_url' => get_option( 'projects_portfolio_default_gitea_base_url', 'https://codeberg.org' ),
'share_telemetry' => get_option( 'projects_portfolio_share_telemetry', '0' ),
'templates' => [
'version' => get_option( 'projects_portfolio_templates_version', '0' ),
'last_updated' => get_option( 'projects_portfolio_templates_last_updated', '0' ),
+32
View File
@@ -0,0 +1,32 @@
<?php
require_once __DIR__ . '/../includes/helper-functions.php';
/**
* @covers \projects_portfolio_settings
*/
class Settings_Test extends \PHPUnit\Framework\TestCase {
protected function setUp(): void {
\Brain\Monkey\setUp();
}
protected function tearDown(): void {
\Brain\Monkey\tearDown();
}
public function test_settings_aggregator_includes_gitea_keys(): void {
\Brain\Monkey\Functions\stubs( [
'get_option' => function ( $key, $default = '' ) {
$values = [
'projects_portfolio_default_gitea_base_url' => 'https://git.example.org',
'projects_portfolio_gitea_api_token' => 'secret',
];
return $values[ $key ] ?? $default;
},
] );
$settings = projects_portfolio_settings();
$this->assertSame( 'https://git.example.org', $settings['default_gitea_base_url'] );
$this->assertSame( 'secret', $settings['gitea_api_token'] );
}
}