Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
->setRiskyAllowed(true)
->setRules([
// Presets
'@PSR12' => true,
'@PSR12:risky' => true,
'@PHP83Migration' => true,
'@PHP80Migration:risky' => true,
'@PER-CS' => true,
'@PER-CS:risky' => true,
'@PHP84Migration' => true,
// PHP-CS-Fixer 3.95 has no @PHP83Migration:risky or @PHP84Migration:risky;
// @PHP82Migration:risky is the latest extant risky migration set and a strict
// superset of @PHP80Migration:risky (the previous setting).
'@PHP82Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,

Expand Down
4 changes: 2 additions & 2 deletions tests/Command/TtSyncSubticketsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function testRunsForAllProjectsWithTicketSystem(): void
->willReturnOnConsecutiveCalls(['X-1', 'X-2'], []);

// Repository mock that returns a minimal query builder-like object
$project = (new Project())->setId(1)->setName('Alpha');
$p2 = (new Project())->setId(2)->setName('Beta');
$project = new Project()->setId(1)->setName('Alpha');
$p2 = new Project()->setId(2)->setName('Beta');
$projectRepo = $this->getMockBuilder(\Doctrine\ORM\EntityRepository::class)
->disableOriginalConstructor()
->onlyMethods(['createQueryBuilder'])
Expand Down
18 changes: 9 additions & 9 deletions tests/Controller/ControllingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public function testExportActionWithBillableAndTicketTitles(): void
$exportServiceMock = $this->createMock(Export::class);

// --- Real entities for export ---
$user = (new \App\Entity\User())->setId(1)->setUsername('unittest');
$customer = (new \App\Entity\Customer())->setId(1)->setName('Test Customer');
$project = (new \App\Entity\Project())->setId(1)->setName('Test Project');
$user = new \App\Entity\User()->setId(1)->setUsername('unittest');
$customer = new \App\Entity\Customer()->setId(1)->setName('Test Customer');
$project = new \App\Entity\Project()->setId(1)->setName('Test Project');

$entry1 = (new \App\Entity\Entry())
$entry1 = new \App\Entity\Entry()
->setId(4)
->setDay(new DateTime('2023-10-15'))
->setStart(new DateTime('2023-10-15 09:00:00'))
Expand All @@ -139,7 +139,7 @@ public function testExportActionWithBillableAndTicketTitles(): void
->setDescription('Real Desc 1');
// ->setActivity(null) // Assuming default is fine or set if needed

$entry2 = (new \App\Entity\Entry())
$entry2 = new \App\Entity\Entry()
->setId(5)
->setDay(new DateTime('2023-10-20'))
->setStart(new DateTime('2023-10-20 11:00:00'))
Expand Down Expand Up @@ -233,11 +233,11 @@ public function testExportActionHidesBillableFieldWhenNotConfigured(): void
$exportServiceMock = $this->createMock(Export::class);

// --- Mock data for export ---
$user = (new \App\Entity\User())->setId(1)->setUsername('testuser');
$customer = (new \App\Entity\Customer())->setId(1)->setName('Test Customer');
$project = (new \App\Entity\Project())->setId(1)->setName('Test Project');
$user = new \App\Entity\User()->setId(1)->setUsername('testuser');
$customer = new \App\Entity\Customer()->setId(1)->setName('Test Customer');
$project = new \App\Entity\Project()->setId(1)->setName('Test Project');

$entry1 = (new \App\Entity\Entry())
$entry1 = new \App\Entity\Entry()
->setId(6)
->setDay(new DateTime('2023-11-05'))
->setStart(new DateTime('2023-11-05 08:00:00'))
Expand Down
4 changes: 2 additions & 2 deletions tests/Performance/PerformanceBenchmarkRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function setupRegressionThresholds(): void
public function runAllBenchmarks(): array
{
$this->benchmarkResults = [
'timestamp' => (new DateTime())->format('c'),
'timestamp' => new DateTime()->format('c'),
'php_version' => PHP_VERSION,
'memory_limit' => ini_get('memory_limit'),
'max_execution_time' => ini_get('max_execution_time'),
Expand Down Expand Up @@ -213,7 +213,7 @@ private function runSingleBenchmark(string $testClass, string $method): array
'execution_time_ms' => round(($endTime - $startTime) * 1000, 2),
'memory_usage_bytes' => $endMemory - $startMemory,
'peak_memory_usage_bytes' => $endPeakMemory - $startPeakMemory,
'timestamp' => (new DateTime())->format('c'),
'timestamp' => new DateTime()->format('c'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Performance/PerformanceDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ private function prepareChartData(array $history): array
if (!is_string($runTimestamp)) {
$runTimestamp = is_scalar($runTimestamp) ? (string) $runTimestamp : date('c');
}
$timestamps[] = (new DateTime($runTimestamp))->format('M d');
$timestamps[] = new DateTime($runTimestamp)->format('M d');

// Calculate average execution time per run
$totalTime = 0;
Expand Down
24 changes: 12 additions & 12 deletions tests/Repository/EntryRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function today(): DateTimeImmutable
};

// Avoid touching Doctrine by creating a partial instance without constructor
$entryRepository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$reflectionProperty = (new ReflectionClass(EntryRepository::class))->getProperty('clock');
$entryRepository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();
$reflectionProperty = new ReflectionClass(EntryRepository::class)->getProperty('clock');
$reflectionProperty->setValue($entryRepository, $clock);

// 1 working day on Monday should include previous Fri,Sat,Sun => 3 calendar days
Expand All @@ -65,9 +65,9 @@ public function today(): DateTimeImmutable
} // Tuesday
};
// Avoid touching Doctrine by creating a partial mock that bypasses parent constructor
$entryRepository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$entryRepository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();
// Inject clock via reflection
$reflectionProperty = (new ReflectionClass(EntryRepository::class))->getProperty('clock');
$reflectionProperty = new ReflectionClass(EntryRepository::class)->getProperty('clock');
$reflectionProperty->setValue($entryRepository, $clock);

self::assertSame(0, $entryRepository->getCalendarDaysByWorkDays(0));
Expand All @@ -89,8 +89,8 @@ public function today(): DateTimeImmutable
} // Monday
};
// Avoid touching Doctrine by creating a partial mock that bypasses parent constructor
$entryRepository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$reflectionProperty = (new ReflectionClass(EntryRepository::class))->getProperty('clock');
$entryRepository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();
$reflectionProperty = new ReflectionClass(EntryRepository::class)->getProperty('clock');
$reflectionProperty->setValue($entryRepository, $clock);

self::assertSame(3, $entryRepository->getCalendarDaysByWorkDays(1)); // Monday spans back to Friday
Expand All @@ -110,8 +110,8 @@ public function today(): DateTimeImmutable
}
};

$entryRepository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$reflectionProperty = (new ReflectionClass(EntryRepository::class))->getProperty('clock');
$entryRepository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();
$reflectionProperty = new ReflectionClass(EntryRepository::class)->getProperty('clock');
$reflectionProperty->setValue($entryRepository, $clock);

self::assertSame(0, $entryRepository->getCalendarDaysByWorkDays(-5));
Expand All @@ -132,8 +132,8 @@ public function today(): DateTimeImmutable
} // Friday
};

$entryRepository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$reflectionProperty = (new ReflectionClass(EntryRepository::class))->getProperty('clock');
$entryRepository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();
$reflectionProperty = new ReflectionClass(EntryRepository::class)->getProperty('clock');
$reflectionProperty->setValue($entryRepository, $clock);

// 1 working day on Friday should be just 1 calendar day
Expand All @@ -158,8 +158,8 @@ public function today(): DateTimeImmutable
} // Wednesday
};

$entryRepository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$reflectionProperty = (new ReflectionClass(EntryRepository::class))->getProperty('clock');
$entryRepository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();
$reflectionProperty = new ReflectionClass(EntryRepository::class)->getProperty('clock');
$reflectionProperty->setValue($entryRepository, $clock);

// 1 working day on Wednesday is just 1 calendar day
Expand Down
2 changes: 1 addition & 1 deletion tests/Repository/EntryRepositoryUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class EntryRepositoryUnitTest extends TestCase
*/
private function createRepositoryWithClock(ClockInterface $clock): EntryRepository
{
$repository = (new ReflectionClass(EntryRepository::class))->newInstanceWithoutConstructor();
$repository = new ReflectionClass(EntryRepository::class)->newInstanceWithoutConstructor();

// Use reflection to set the readonly property before it's initialized
$reflectionClass = new ReflectionClass(EntryRepository::class);
Expand Down
6 changes: 3 additions & 3 deletions tests/Security/LdapAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function testAuthenticateReturnsExistingUser(): void
{
$this->configureDefaultLdapParams();

$existingUser = (new User())->setUsername('testuser');
$existingUser = new User()->setUsername('testuser');

$userRepo = $this->createMock(UserRepository::class);
$userRepo->method('findOneBy')->willReturn($existingUser);
Expand Down Expand Up @@ -278,7 +278,7 @@ public function testAuthenticateCreatesUserWithTeams(): void
{
$this->configureDefaultLdapParams();

$team = (new Team())->setName('Dev Team');
$team = new Team()->setName('Dev Team');

$userRepo = $this->createMock(UserRepository::class);
$userRepo->method('findOneBy')->willReturn(null);
Expand Down Expand Up @@ -584,7 +584,7 @@ public function testAuthenticateWithValidEmailUsername(): void
{
$this->configureDefaultLdapParams();

$existingUser = (new User())->setUsername('user@example.com');
$existingUser = new User()->setUsername('user@example.com');

$userRepo = $this->createMock(UserRepository::class);
$userRepo->method('findOneBy')->willReturn($existingUser);
Expand Down
Loading
Loading