- ShopProduct factory: full migration (~40 ProductRepository methods, ~30 controller actions) - Dashboard: Domain+DI migration (DashboardRepository + DashboardController) - Update: Domain+DI migration (UpdateRepository + UpdateController, template rewrite) - Renamed admin\Site to admin\App, removed dead fallback routing - Removed all legacy folders: admin/controls, admin/factory, admin/view - Newsletter: switched from admin\factory\Articles to ArticleRepository - 414 tests, 1335 assertions passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
namespace Tests\Unit\Domain\Update;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Domain\Update\UpdateRepository;
|
|
|
|
class UpdateRepositoryTest extends TestCase
|
|
{
|
|
private function createMockDb(): \medoo
|
|
{
|
|
return $this->createMock(\medoo::class);
|
|
}
|
|
|
|
public function testConstructorAcceptsDb(): void
|
|
{
|
|
$db = $this->createMockDb();
|
|
$repository = new UpdateRepository($db);
|
|
$this->assertInstanceOf(UpdateRepository::class, $repository);
|
|
}
|
|
|
|
public function testHasUpdateMethod(): void
|
|
{
|
|
$db = $this->createMockDb();
|
|
$repository = new UpdateRepository($db);
|
|
$this->assertTrue(method_exists($repository, 'update'));
|
|
}
|
|
|
|
public function testUpdateReturnsArray(): void
|
|
{
|
|
$db = $this->createMockDb();
|
|
$repository = new UpdateRepository($db);
|
|
|
|
$reflection = new \ReflectionClass($repository);
|
|
$method = $reflection->getMethod('update');
|
|
$this->assertEquals('array', (string)$method->getReturnType());
|
|
}
|
|
|
|
public function testHasRunPendingMigrationsMethod(): void
|
|
{
|
|
$db = $this->createMockDb();
|
|
$repository = new UpdateRepository($db);
|
|
$this->assertTrue(method_exists($repository, 'runPendingMigrations'));
|
|
}
|
|
|
|
public function testRunPendingMigrationsWithNoResults(): void
|
|
{
|
|
$db = $this->createMockDb();
|
|
$db->method('select')->willReturn(false);
|
|
|
|
$repository = new UpdateRepository($db);
|
|
$repository->runPendingMigrations();
|
|
|
|
$this->assertTrue(true); // No exception thrown
|
|
}
|
|
|
|
public function testHasPrivateHelperMethods(): void
|
|
{
|
|
$reflection = new \ReflectionClass(UpdateRepository::class);
|
|
|
|
$privateMethods = [
|
|
'downloadAndApply',
|
|
'executeSql',
|
|
'deleteFiles',
|
|
'extractZip',
|
|
'saveLog',
|
|
];
|
|
|
|
foreach ($privateMethods as $methodName) {
|
|
$this->assertTrue(
|
|
$reflection->hasMethod($methodName),
|
|
"Missing private method: {$methodName}"
|
|
);
|
|
$method = $reflection->getMethod($methodName);
|
|
$this->assertTrue(
|
|
$method->isPrivate(),
|
|
"Method {$methodName} should be private"
|
|
);
|
|
}
|
|
}
|
|
}
|