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:
parent
3df38de9fb
commit
16f8631fd4
@ -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';
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
@ -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 = [
|
||||
|
@ -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 {
|
||||
|
@ -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 = [
|
||||
|
@ -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)[]];
|
||||
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user