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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user