ver. 0.287: Scontainers + ShopAttribute frontend migration to Domain
- Scontainers: frontScontainerDetails() with Redis cache in ScontainersRepository - Scontainers: new front\Views\Scontainers VIEW, deleted factory + view legacy - ShopAttribute: frontAttributeDetails(), frontValueDetails() with Redis cache in AttributeRepository - ShopAttribute: clearFrontCache() per attribute/value + language - ShopAttribute: deleted front\factory\ShopAttribute, updated 4 callers - Tests: 476 OK, 1512 assertions (+6 frontend tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -258,6 +258,75 @@ class AttributeRepositoryTest extends TestCase
|
||||
$this->assertSame('Czerwony', $result);
|
||||
}
|
||||
|
||||
// ── Frontend methods tests ──────────────────────────────────
|
||||
|
||||
public function testFrontAttributeDetailsReturnsAttributeWithLanguage(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
$mockDb->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->willReturnOnConsecutiveCalls(
|
||||
['id' => 5, 'status' => 1, 'type' => 0, 'o' => 2],
|
||||
['lang_id' => 'pl', 'name' => 'Kolor']
|
||||
);
|
||||
|
||||
$repository = new AttributeRepository($mockDb);
|
||||
$result = $repository->frontAttributeDetails(5, 'pl');
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertSame(5, (int)$result['id']);
|
||||
$this->assertSame('Kolor', $result['language']['name']);
|
||||
$this->assertSame('pl', $result['language']['lang_id']);
|
||||
}
|
||||
|
||||
public function testFrontAttributeDetailsReturnsFallbackForNotFound(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
$mockDb->method('get')->willReturn(null);
|
||||
|
||||
$repository = new AttributeRepository($mockDb);
|
||||
$result = $repository->frontAttributeDetails(999, 'pl');
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertSame(999, (int)$result['id']);
|
||||
$this->assertSame(0, (int)$result['status']);
|
||||
$this->assertSame('pl', $result['language']['lang_id']);
|
||||
$this->assertSame('', $result['language']['name']);
|
||||
}
|
||||
|
||||
public function testFrontValueDetailsReturnsValueWithLanguage(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
$mockDb->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->willReturnOnConsecutiveCalls(
|
||||
['id' => 12, 'attribute_id' => 5, 'is_default' => 1, 'impact_on_the_price' => null],
|
||||
['lang_id' => 'pl', 'name' => 'Czerwony']
|
||||
);
|
||||
|
||||
$repository = new AttributeRepository($mockDb);
|
||||
$result = $repository->frontValueDetails(12, 'pl');
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertSame(12, (int)$result['id']);
|
||||
$this->assertSame('Czerwony', $result['language']['name']);
|
||||
$this->assertSame('pl', $result['language']['lang_id']);
|
||||
}
|
||||
|
||||
public function testFrontValueDetailsReturnsFallbackForNotFound(): void
|
||||
{
|
||||
$mockDb = $this->createMock(\medoo::class);
|
||||
$mockDb->method('get')->willReturn(null);
|
||||
|
||||
$repository = new AttributeRepository($mockDb);
|
||||
$result = $repository->frontValueDetails(999, 'en');
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertSame(999, (int)$result['id']);
|
||||
$this->assertSame('en', $result['language']['lang_id']);
|
||||
$this->assertSame('', $result['language']['name']);
|
||||
}
|
||||
|
||||
private function hasDeleteCall(array $calls, string $table, array $where): bool
|
||||
{
|
||||
foreach ($calls as $call) {
|
||||
|
||||
Reference in New Issue
Block a user