Add new settings and cache repository files, update admin settings controller and templates

- Introduced new `SettingsRepository` and `CacheRepository` classes in the `autoload\Domain` namespace.
- Updated `SettingsController` in the `admin\Controllers` namespace to enhance settings management.
- Added new templates for settings in `admin\templates\settings` and `admin\templates\site`.
- Improved overall structure and organization of settings-related files.
This commit is contained in:
2026-02-05 23:32:48 +01:00
parent 3a7be21432
commit 1c88f8adfa
35 changed files with 1233 additions and 87 deletions

View File

@@ -115,6 +115,132 @@ class ProductRepositoryTest extends TestCase
$this->assertTrue($result);
}
/**
* Test pobierania ceny - zwraca cenę regularną gdy brak promocji
*/
public function testGetPriceReturnsRegularPrice()
{
// Arrange
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('get')->willReturn([
'price_brutto' => '99.99',
'price_brutto_promo' => ''
]);
$repository = new ProductRepository($mockDb);
// Act
$price = $repository->getPrice(123);
// Assert
$this->assertEquals(99.99, $price);
$this->assertIsFloat($price);
}
/**
* Test pobierania ceny - zwraca cenę promocyjną gdy jest niższa
*/
public function testGetPriceReturnsPromoPrice()
{
// Arrange
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('get')->willReturn([
'price_brutto' => '99.99',
'price_brutto_promo' => '79.99'
]);
$repository = new ProductRepository($mockDb);
// Act
$price = $repository->getPrice(123);
// Assert
$this->assertEquals(79.99, $price);
}
/**
* Test pobierania ceny - zwraca regularną gdy promo jest wyższa
*/
public function testGetPriceReturnsRegularWhenPromoIsHigher()
{
// Arrange
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('get')->willReturn([
'price_brutto' => '49.99',
'price_brutto_promo' => '79.99'
]);
$repository = new ProductRepository($mockDb);
// Act
$price = $repository->getPrice(123);
// Assert
$this->assertEquals(49.99, $price);
}
/**
* Test pobierania ceny - zwraca null gdy produkt nie istnieje
*/
public function testGetPriceReturnsNullWhenNotFound()
{
// Arrange
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('get')->willReturn(false);
$repository = new ProductRepository($mockDb);
// Act
$price = $repository->getPrice(999);
// Assert
$this->assertNull($price);
}
/**
* Test pobierania nazwy produktu - zwraca nazwę
*/
public function testGetNameReturnsProductName()
{
// Arrange
$mockDb = $this->createMock(\medoo::class);
$mockDb->expects($this->once())
->method('get')
->with(
$this->equalTo('pp_shop_products_langs'),
$this->equalTo('name'),
$this->equalTo(['AND' => ['product_id' => 123, 'lang_id' => 'pl']])
)
->willReturn('Testowy produkt');
$repository = new ProductRepository($mockDb);
// Act
$name = $repository->getName(123, 'pl');
// Assert
$this->assertEquals('Testowy produkt', $name);
$this->assertIsString($name);
}
/**
* Test pobierania nazwy - produkt nie istnieje
*/
public function testGetNameReturnsNullWhenNotFound()
{
// Arrange
$mockDb = $this->createMock(\medoo::class);
$mockDb->method('get')->willReturn(false);
$repository = new ProductRepository($mockDb);
// Act
$name = $repository->getName(999, 'pl');
// Assert
$this->assertNull($name);
}
/**
* Test typu zwracanej wartości
*/