Fix cases where I missed renaming config to settings (#63)

Reviewed-on: https://gitea.subcultureofone.org/greg/tkr/pulls/63
Co-authored-by: Greg Sarjeant <greg@subcultureofone.org>
Co-committed-by: Greg Sarjeant <greg@subcultureofone.org>
This commit is contained in:
Greg Sarjeant 2025-08-08 20:03:44 +00:00 committed by greg
parent 3df38de9fb
commit 16f8631fd4
9 changed files with 39 additions and 39 deletions

View File

@ -15,7 +15,7 @@ class AdminControllerTest extends TestCase
// Create mock PDO // Create mock PDO
$this->mockPdo = $this->createMock(PDO::class); $this->mockPdo = $this->createMock(PDO::class);
// Create real config and user objects with mocked PDO // Create real settings and user objects with mocked PDO
$this->settings = new SettingsModel($this->mockPdo); $this->settings = new SettingsModel($this->mockPdo);
$this->settings->siteTitle = 'Test Site'; $this->settings->siteTitle = 'Test Site';
$this->settings->siteDescription = 'Test Description'; $this->settings->siteDescription = 'Test Description';

View File

@ -7,7 +7,7 @@ class FeedControllerTest extends TestCase
{ {
private PDO $mockPdo; private PDO $mockPdo;
private PDOStatement $mockStatement; private PDOStatement $mockStatement;
private SettingsModel $mockConfig; private SettingsModel $mockSettings;
private UserModel $mockUser; private UserModel $mockUser;
private string $tempLogDir; private string $tempLogDir;
@ -22,13 +22,13 @@ class FeedControllerTest extends TestCase
$this->mockStatement = $this->createMock(PDOStatement::class); $this->mockStatement = $this->createMock(PDOStatement::class);
$this->mockPdo = $this->createMock(PDO::class); $this->mockPdo = $this->createMock(PDO::class);
// Mock config with feed-relevant properties // Mock settings with feed-relevant properties
$this->mockConfig = new SettingsModel($this->mockPdo); $this->mockSettings = new SettingsModel($this->mockPdo);
$this->mockConfig->itemsPerPage = 10; $this->mockSettings->itemsPerPage = 10;
$this->mockConfig->basePath = '/tkr'; $this->mockSettings->basePath = '/tkr';
$this->mockConfig->siteTitle = 'Test Site'; $this->mockSettings->siteTitle = 'Test Site';
$this->mockConfig->siteDescription = 'Test Description'; $this->mockSettings->siteDescription = 'Test Description';
$this->mockConfig->baseUrl = 'https://test.example.com'; $this->mockSettings->baseUrl = 'https://test.example.com';
// Mock user // Mock user
$this->mockUser = new UserModel($this->mockPdo); $this->mockUser = new UserModel($this->mockPdo);
@ -38,12 +38,12 @@ class FeedControllerTest extends TestCase
global $app; global $app;
$app = [ $app = [
'db' => $this->mockPdo, 'db' => $this->mockPdo,
'settings' => $this->mockConfig, 'settings' => $this->mockSettings,
'user' => $this->mockUser, 'user' => $this->mockUser,
]; ];
// Set log level on config for Log class // Set log level on settings for Log class
$this->mockConfig->logLevel = 1; // Allow DEBUG level logs $this->mockSettings->logLevel = 1; // Allow DEBUG level logs
} }
protected function tearDown(): void protected function tearDown(): void

View File

@ -7,7 +7,7 @@ class HomeControllerTest extends TestCase
{ {
private PDO $mockPdo; private PDO $mockPdo;
private PDOStatement $mockStatement; private PDOStatement $mockStatement;
private SettingsModel $mockConfig; private SettingsModel $mockSettings;
private UserModel $mockUser; private UserModel $mockUser;
protected function setUp(): void protected function setUp(): void
@ -19,10 +19,10 @@ class HomeControllerTest extends TestCase
$this->mockStatement = $this->createMock(PDOStatement::class); $this->mockStatement = $this->createMock(PDOStatement::class);
$this->mockPdo = $this->createMock(PDO::class); $this->mockPdo = $this->createMock(PDO::class);
// Mock config // Mock settings
$this->mockConfig = new SettingsModel($this->mockPdo); $this->mockSettings = new SettingsModel($this->mockPdo);
$this->mockConfig->itemsPerPage = 10; $this->mockSettings->itemsPerPage = 10;
$this->mockConfig->basePath = '/tkr'; $this->mockSettings->basePath = '/tkr';
// Mock user // Mock user
$this->mockUser = new UserModel($this->mockPdo); $this->mockUser = new UserModel($this->mockPdo);
@ -33,7 +33,7 @@ class HomeControllerTest extends TestCase
global $app; global $app;
$app = [ $app = [
'db' => $this->mockPdo, 'db' => $this->mockPdo,
'settings' => $this->mockConfig, 'settings' => $this->mockSettings,
'user' => $this->mockUser, 'user' => $this->mockUser,
]; ];
} }
@ -81,8 +81,8 @@ class HomeControllerTest extends TestCase
$this->assertArrayHasKey('user', $data); $this->assertArrayHasKey('user', $data);
$this->assertArrayHasKey('tickList', $data); $this->assertArrayHasKey('tickList', $data);
// Config and user should be the injected instances // Settings and user should be the injected instances
$this->assertSame($this->mockConfig, $data['settings']); $this->assertSame($this->mockSettings, $data['settings']);
$this->assertSame($this->mockUser, $data['user']); $this->assertSame($this->mockUser, $data['user']);
// Should have tick list HTML (even if empty) // Should have tick list HTML (even if empty)

View File

@ -23,16 +23,16 @@ class LogControllerTest extends TestCase
// Set up global $app for simplified dependency access // Set up global $app for simplified dependency access
$mockPdo = $this->createMock(PDO::class); $mockPdo = $this->createMock(PDO::class);
$mockConfig = new SettingsModel($mockPdo); $mockSettings = new SettingsModel($mockPdo);
$mockConfig->baseUrl = 'https://example.com'; $mockSettings->baseUrl = 'https://example.com';
$mockConfig->basePath = '/tkr/'; $mockSettings->basePath = '/tkr/';
$mockUser = new UserModel($mockPdo); $mockUser = new UserModel($mockPdo);
global $app; global $app;
$app = [ $app = [
'db' => $mockPdo, 'db' => $mockPdo,
'settings' => $mockConfig, 'settings' => $mockSettings,
'user' => $mockUser, 'user' => $mockUser,
]; ];
} }

View File

@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase;
class AtomGeneratorTest extends TestCase class AtomGeneratorTest extends TestCase
{ {
private function createMockConfig() { private function createMockSettings() {
$mockPdo = $this->createMock(PDO::class); $mockPdo = $this->createMock(PDO::class);
$settings = new SettingsModel($mockPdo); $settings = new SettingsModel($mockPdo);
$settings->siteTitle = 'Test Site'; $settings->siteTitle = 'Test Site';
@ -23,7 +23,7 @@ class AtomGeneratorTest extends TestCase
} }
public function testCanGenerateValidAtom() { public function testCanGenerateValidAtom() {
$settings = $this->createMockConfig(); $settings = $this->createMockSettings();
$ticks = $this->createSampleTicks(); $ticks = $this->createSampleTicks();
$generator = new AtomGenerator($settings, $ticks); $generator = new AtomGenerator($settings, $ticks);
@ -53,12 +53,12 @@ class AtomGeneratorTest extends TestCase
} }
public function testReturnsCorrectContentType() { public function testReturnsCorrectContentType() {
$generator = new AtomGenerator($this->createMockConfig(), []); $generator = new AtomGenerator($this->createMockSettings(), []);
$this->assertEquals('application/atom+xml; charset=utf-8', $generator->getContentType()); $this->assertEquals('application/atom+xml; charset=utf-8', $generator->getContentType());
} }
public function testCanHandleEmptyTickList() { public function testCanHandleEmptyTickList() {
$settings = $this->createMockConfig(); $settings = $this->createMockSettings();
$generator = new AtomGenerator($settings, []); $generator = new AtomGenerator($settings, []);
$xml = $generator->generate(); $xml = $generator->generate();
@ -85,7 +85,7 @@ class AtomGeneratorTest extends TestCase
} }
public function testCanHandleSpecialCharactersAndUnicode() { public function testCanHandleSpecialCharactersAndUnicode() {
$settings = $this->createMockConfig(); $settings = $this->createMockSettings();
// Test various challenging characters // Test various challenging characters
$ticks = [ $ticks = [

View File

@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase;
class FeedGeneratorTest extends TestCase class FeedGeneratorTest extends TestCase
{ {
private function createMockConfig() { private function createMockSettings() {
$mockPdo = $this->createMock(PDO::class); $mockPdo = $this->createMock(PDO::class);
$settings = new SettingsModel($mockPdo); $settings = new SettingsModel($mockPdo);
$settings->siteTitle = 'Test Site'; $settings->siteTitle = 'Test Site';
@ -23,7 +23,7 @@ class FeedGeneratorTest extends TestCase
} }
private function createTestGenerator($settings = null, $ticks = null) { private function createTestGenerator($settings = null, $ticks = null) {
$settings = $settings ?? $this->createMockConfig(); $settings = $settings ?? $this->createMockSettings();
$ticks = $ticks ?? $this->createSampleTicks(); $ticks = $ticks ?? $this->createSampleTicks();
return new class($settings, $ticks) extends FeedGenerator { return new class($settings, $ticks) extends FeedGenerator {

View File

@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase;
class RssGeneratorTest extends TestCase class RssGeneratorTest extends TestCase
{ {
private function createMockConfig() { private function createMockSettings() {
$mockPdo = $this->createMock(PDO::class); $mockPdo = $this->createMock(PDO::class);
$settings = new SettingsModel($mockPdo); $settings = new SettingsModel($mockPdo);
$settings->siteTitle = 'Test Site'; $settings->siteTitle = 'Test Site';
@ -23,7 +23,7 @@ class RssGeneratorTest extends TestCase
} }
public function testCanGenerateValidRss() { public function testCanGenerateValidRss() {
$settings = $this->createMockConfig(); $settings = $this->createMockSettings();
$ticks = $this->createSampleTicks(); $ticks = $this->createSampleTicks();
$generator = new RssGenerator($settings, $ticks); $generator = new RssGenerator($settings, $ticks);
@ -51,12 +51,12 @@ class RssGeneratorTest extends TestCase
} }
public function testReturnsCorrectContentType() { public function testReturnsCorrectContentType() {
$generator = new RssGenerator($this->createMockConfig(), []); $generator = new RssGenerator($this->createMockSettings(), []);
$this->assertEquals('application/rss+xml; charset=utf-8', $generator->getContentType()); $this->assertEquals('application/rss+xml; charset=utf-8', $generator->getContentType());
} }
public function testCanHandleEmptyTickList() { public function testCanHandleEmptyTickList() {
$settings = $this->createMockConfig(); $settings = $this->createMockSettings();
$generator = new RssGenerator($settings, []); $generator = new RssGenerator($settings, []);
$xml = $generator->generate(); $xml = $generator->generate();
@ -81,7 +81,7 @@ class RssGeneratorTest extends TestCase
} }
public function testCanHandleSpecialCharactersAndUnicode() { public function testCanHandleSpecialCharactersAndUnicode() {
$settings = $this->createMockConfig(); $settings = $this->createMockSettings();
// Test various challenging characters // Test various challenging characters
$ticks = [ $ticks = [

View File

@ -184,9 +184,9 @@ class LogTest extends TestCase
$this->assertLogContains('Trigger rotation with max files'); $this->assertLogContains('Trigger rotation with max files');
} }
public function testDefaultLogLevelWhenConfigMissing(): void public function testDefaultLogLevelWhenSettingsMissing(): void
{ {
// Set up config without logLevel property (simulates missing config value) // Set up settings without logLevel property (simulates missing settings value)
global $app; global $app;
$app = ['settings' => (object)[]]; $app = ['settings' => (object)[]];

View File

@ -148,7 +148,7 @@ final class UtilTest extends TestCase
#[DataProvider('linkifyProvider')] #[DataProvider('linkifyProvider')]
public function testLinkify(string $input, string $expected, bool $strictAccessibility): void { public function testLinkify(string $input, string $expected, bool $strictAccessibility): void {
// Set up global $app with config // Set up global $app with settings
global $app; global $app;
$app = [ $app = [
'settings' => (object)['strictAccessibility' => $strictAccessibility] 'settings' => (object)['strictAccessibility' => $strictAccessibility]