From 16f8631fd4d5bad3539fba75afbeb2af653c4a86 Mon Sep 17 00:00:00 2001 From: Greg Sarjeant Date: Fri, 8 Aug 2025 20:03:44 +0000 Subject: [PATCH] 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 Co-committed-by: Greg Sarjeant --- .../AdminController/AdminControllerTest.php | 2 +- .../FeedController/FeedControllerTest.php | 22 +++++++++---------- .../HomeController/HomeControllerTest.php | 16 +++++++------- .../LogController/LogControllerTest.php | 8 +++---- tests/Feed/AtomGeneratorTest.php | 10 ++++----- tests/Feed/FeedGeneratorTest.php | 4 ++-- tests/Feed/RssGeneratorTest.php | 10 ++++----- tests/Framework/Log/LogTest.php | 4 ++-- tests/Framework/Util/UtilTest.php | 2 +- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/Controller/AdminController/AdminControllerTest.php b/tests/Controller/AdminController/AdminControllerTest.php index 95494a8..c47cd83 100644 --- a/tests/Controller/AdminController/AdminControllerTest.php +++ b/tests/Controller/AdminController/AdminControllerTest.php @@ -15,7 +15,7 @@ class AdminControllerTest extends TestCase // Create mock PDO $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->siteTitle = 'Test Site'; $this->settings->siteDescription = 'Test Description'; diff --git a/tests/Controller/FeedController/FeedControllerTest.php b/tests/Controller/FeedController/FeedControllerTest.php index 6d50840..bd51ce0 100644 --- a/tests/Controller/FeedController/FeedControllerTest.php +++ b/tests/Controller/FeedController/FeedControllerTest.php @@ -7,7 +7,7 @@ class FeedControllerTest extends TestCase { private PDO $mockPdo; private PDOStatement $mockStatement; - private SettingsModel $mockConfig; + private SettingsModel $mockSettings; private UserModel $mockUser; private string $tempLogDir; @@ -22,13 +22,13 @@ class FeedControllerTest extends TestCase $this->mockStatement = $this->createMock(PDOStatement::class); $this->mockPdo = $this->createMock(PDO::class); - // Mock config with feed-relevant properties - $this->mockConfig = new SettingsModel($this->mockPdo); - $this->mockConfig->itemsPerPage = 10; - $this->mockConfig->basePath = '/tkr'; - $this->mockConfig->siteTitle = 'Test Site'; - $this->mockConfig->siteDescription = 'Test Description'; - $this->mockConfig->baseUrl = 'https://test.example.com'; + // Mock settings with feed-relevant properties + $this->mockSettings = new SettingsModel($this->mockPdo); + $this->mockSettings->itemsPerPage = 10; + $this->mockSettings->basePath = '/tkr'; + $this->mockSettings->siteTitle = 'Test Site'; + $this->mockSettings->siteDescription = 'Test Description'; + $this->mockSettings->baseUrl = 'https://test.example.com'; // Mock user $this->mockUser = new UserModel($this->mockPdo); @@ -38,12 +38,12 @@ class FeedControllerTest extends TestCase global $app; $app = [ 'db' => $this->mockPdo, - 'settings' => $this->mockConfig, + 'settings' => $this->mockSettings, 'user' => $this->mockUser, ]; - // Set log level on config for Log class - $this->mockConfig->logLevel = 1; // Allow DEBUG level logs + // Set log level on settings for Log class + $this->mockSettings->logLevel = 1; // Allow DEBUG level logs } protected function tearDown(): void diff --git a/tests/Controller/HomeController/HomeControllerTest.php b/tests/Controller/HomeController/HomeControllerTest.php index a8460b3..068e574 100644 --- a/tests/Controller/HomeController/HomeControllerTest.php +++ b/tests/Controller/HomeController/HomeControllerTest.php @@ -7,7 +7,7 @@ class HomeControllerTest extends TestCase { private PDO $mockPdo; private PDOStatement $mockStatement; - private SettingsModel $mockConfig; + private SettingsModel $mockSettings; private UserModel $mockUser; protected function setUp(): void @@ -19,10 +19,10 @@ class HomeControllerTest extends TestCase $this->mockStatement = $this->createMock(PDOStatement::class); $this->mockPdo = $this->createMock(PDO::class); - // Mock config - $this->mockConfig = new SettingsModel($this->mockPdo); - $this->mockConfig->itemsPerPage = 10; - $this->mockConfig->basePath = '/tkr'; + // Mock settings + $this->mockSettings = new SettingsModel($this->mockPdo); + $this->mockSettings->itemsPerPage = 10; + $this->mockSettings->basePath = '/tkr'; // Mock user $this->mockUser = new UserModel($this->mockPdo); @@ -33,7 +33,7 @@ class HomeControllerTest extends TestCase global $app; $app = [ 'db' => $this->mockPdo, - 'settings' => $this->mockConfig, + 'settings' => $this->mockSettings, 'user' => $this->mockUser, ]; } @@ -81,8 +81,8 @@ class HomeControllerTest extends TestCase $this->assertArrayHasKey('user', $data); $this->assertArrayHasKey('tickList', $data); - // Config and user should be the injected instances - $this->assertSame($this->mockConfig, $data['settings']); + // Settings and user should be the injected instances + $this->assertSame($this->mockSettings, $data['settings']); $this->assertSame($this->mockUser, $data['user']); // Should have tick list HTML (even if empty) diff --git a/tests/Controller/LogController/LogControllerTest.php b/tests/Controller/LogController/LogControllerTest.php index 92b2446..e9cb294 100644 --- a/tests/Controller/LogController/LogControllerTest.php +++ b/tests/Controller/LogController/LogControllerTest.php @@ -23,16 +23,16 @@ class LogControllerTest extends TestCase // Set up global $app for simplified dependency access $mockPdo = $this->createMock(PDO::class); - $mockConfig = new SettingsModel($mockPdo); - $mockConfig->baseUrl = 'https://example.com'; - $mockConfig->basePath = '/tkr/'; + $mockSettings = new SettingsModel($mockPdo); + $mockSettings->baseUrl = 'https://example.com'; + $mockSettings->basePath = '/tkr/'; $mockUser = new UserModel($mockPdo); global $app; $app = [ 'db' => $mockPdo, - 'settings' => $mockConfig, + 'settings' => $mockSettings, 'user' => $mockUser, ]; } diff --git a/tests/Feed/AtomGeneratorTest.php b/tests/Feed/AtomGeneratorTest.php index fcaf02d..0adc56a 100644 --- a/tests/Feed/AtomGeneratorTest.php +++ b/tests/Feed/AtomGeneratorTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; class AtomGeneratorTest extends TestCase { - private function createMockConfig() { + private function createMockSettings() { $mockPdo = $this->createMock(PDO::class); $settings = new SettingsModel($mockPdo); $settings->siteTitle = 'Test Site'; @@ -23,7 +23,7 @@ class AtomGeneratorTest extends TestCase } public function testCanGenerateValidAtom() { - $settings = $this->createMockConfig(); + $settings = $this->createMockSettings(); $ticks = $this->createSampleTicks(); $generator = new AtomGenerator($settings, $ticks); @@ -53,12 +53,12 @@ class AtomGeneratorTest extends TestCase } public function testReturnsCorrectContentType() { - $generator = new AtomGenerator($this->createMockConfig(), []); + $generator = new AtomGenerator($this->createMockSettings(), []); $this->assertEquals('application/atom+xml; charset=utf-8', $generator->getContentType()); } public function testCanHandleEmptyTickList() { - $settings = $this->createMockConfig(); + $settings = $this->createMockSettings(); $generator = new AtomGenerator($settings, []); $xml = $generator->generate(); @@ -85,7 +85,7 @@ class AtomGeneratorTest extends TestCase } public function testCanHandleSpecialCharactersAndUnicode() { - $settings = $this->createMockConfig(); + $settings = $this->createMockSettings(); // Test various challenging characters $ticks = [ diff --git a/tests/Feed/FeedGeneratorTest.php b/tests/Feed/FeedGeneratorTest.php index c6e9eed..d25d442 100644 --- a/tests/Feed/FeedGeneratorTest.php +++ b/tests/Feed/FeedGeneratorTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; class FeedGeneratorTest extends TestCase { - private function createMockConfig() { + private function createMockSettings() { $mockPdo = $this->createMock(PDO::class); $settings = new SettingsModel($mockPdo); $settings->siteTitle = 'Test Site'; @@ -23,7 +23,7 @@ class FeedGeneratorTest extends TestCase } private function createTestGenerator($settings = null, $ticks = null) { - $settings = $settings ?? $this->createMockConfig(); + $settings = $settings ?? $this->createMockSettings(); $ticks = $ticks ?? $this->createSampleTicks(); return new class($settings, $ticks) extends FeedGenerator { diff --git a/tests/Feed/RssGeneratorTest.php b/tests/Feed/RssGeneratorTest.php index 270728c..55b14be 100644 --- a/tests/Feed/RssGeneratorTest.php +++ b/tests/Feed/RssGeneratorTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; class RssGeneratorTest extends TestCase { - private function createMockConfig() { + private function createMockSettings() { $mockPdo = $this->createMock(PDO::class); $settings = new SettingsModel($mockPdo); $settings->siteTitle = 'Test Site'; @@ -23,7 +23,7 @@ class RssGeneratorTest extends TestCase } public function testCanGenerateValidRss() { - $settings = $this->createMockConfig(); + $settings = $this->createMockSettings(); $ticks = $this->createSampleTicks(); $generator = new RssGenerator($settings, $ticks); @@ -51,12 +51,12 @@ class RssGeneratorTest extends TestCase } public function testReturnsCorrectContentType() { - $generator = new RssGenerator($this->createMockConfig(), []); + $generator = new RssGenerator($this->createMockSettings(), []); $this->assertEquals('application/rss+xml; charset=utf-8', $generator->getContentType()); } public function testCanHandleEmptyTickList() { - $settings = $this->createMockConfig(); + $settings = $this->createMockSettings(); $generator = new RssGenerator($settings, []); $xml = $generator->generate(); @@ -81,7 +81,7 @@ class RssGeneratorTest extends TestCase } public function testCanHandleSpecialCharactersAndUnicode() { - $settings = $this->createMockConfig(); + $settings = $this->createMockSettings(); // Test various challenging characters $ticks = [ diff --git a/tests/Framework/Log/LogTest.php b/tests/Framework/Log/LogTest.php index ab225af..fbc03d0 100644 --- a/tests/Framework/Log/LogTest.php +++ b/tests/Framework/Log/LogTest.php @@ -184,9 +184,9 @@ class LogTest extends TestCase $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; $app = ['settings' => (object)[]]; diff --git a/tests/Framework/Util/UtilTest.php b/tests/Framework/Util/UtilTest.php index eacda25..7399a8f 100644 --- a/tests/Framework/Util/UtilTest.php +++ b/tests/Framework/Util/UtilTest.php @@ -148,7 +148,7 @@ final class UtilTest extends TestCase #[DataProvider('linkifyProvider')] public function testLinkify(string $input, string $expected, bool $strictAccessibility): void { - // Set up global $app with config + // Set up global $app with settings global $app; $app = [ 'settings' => (object)['strictAccessibility' => $strictAccessibility]