ver. 0.292: ShopProduct + ShopPaymentMethod + ShopPromotion + ShopStatuses + ShopTransport frontend migration to Domain

Full migration of front\factory\ — entire directory removed (all 20 classes migrated).
ProductRepository +20 frontend methods, PromotionRepository +5 applyType methods,
TransportRepository +4 cached methods, PaymentMethodRepository +cached frontend methods.
Fix: broken transports_list() in ajax.php replaced with forPaymentMethod().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 21:55:16 +01:00
parent 6181ef958d
commit d14018a5f3
48 changed files with 1780 additions and 975 deletions

View File

@@ -301,6 +301,92 @@ class PaymentMethodRepositoryTest extends TestCase
$this->assertSame('BANK_TRANSFER', $repository->getApiloPaymentTypeId(3));
}
public function testIsActiveReturnsOneForActivePayment(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->once())
->method('get')
->with('pp_shop_payment_methods', 'status', ['id' => 2])
->willReturn('1');
$repository = new PaymentMethodRepository($mockDb);
$this->assertSame(1, $repository->isActive(2));
}
public function testIsActiveReturnsZeroForInvalidId(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->never())->method('get');
$repository = new PaymentMethodRepository($mockDb);
$this->assertSame(0, $repository->isActive(0));
}
public function testFindActiveByIdReturnsNormalizedData(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->once())
->method('get')
->with('pp_shop_payment_methods', '*', [
'AND' => [
'id' => 3,
'status' => 1,
],
])
->willReturn([
'id' => '3',
'name' => ' Przelew ',
'description' => 'Opis',
'status' => '1',
'apilo_payment_type_id' => '5',
]);
$repository = new PaymentMethodRepository($mockDb);
$result = $repository->findActiveById(3);
$this->assertIsArray($result);
$this->assertSame(3, $result['id']);
$this->assertSame('Przelew', $result['name']);
$this->assertSame(1, $result['status']);
$this->assertSame(5, $result['apilo_payment_type_id']);
}
public function testFindActiveByIdReturnsNullForInvalidId(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->never())->method('get');
$repository = new PaymentMethodRepository($mockDb);
$this->assertNull($repository->findActiveById(0));
}
public function testAllActiveReturnsEmptyOnNull(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('select')->willReturn(null);
$repository = new PaymentMethodRepository($mockDb);
$this->assertSame([], $repository->allActive());
}
public function testGetApiloPaymentTypeIdReturnsNullForInvalidId(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->never())->method('get');
$repository = new PaymentMethodRepository($mockDb);
$this->assertNull($repository->getApiloPaymentTypeId(0));
}
public function testForTransportReturnsEmptyForInvalidId(): void
{
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->never())->method('query');
$repository = new PaymentMethodRepository($mockDb);
$this->assertSame([], $repository->forTransport(0));
}
public function testForTransportReturnsRows(): void
{
$mockDb = $this->createMock(\medoo::class);