feat: Add Transport module with repository, controller, and views
- Implemented TransportRepository for managing transport data with methods for listing, finding, saving, and retrieving transport costs. - Created ShopTransportController to handle transport-related actions, including listing, editing, and saving transports. - Added views for transport management: transports list and transport edit forms. - Introduced JavaScript for responsive tabs in transport edit view. - Updated testing suite with comprehensive unit tests for TransportRepository and ShopTransportController. - Increased test coverage with new assertions and scenarios for transport functionalities.
This commit is contained in:
67
tests/Unit/admin/Controllers/ShopTransportControllerTest.php
Normal file
67
tests/Unit/admin/Controllers/ShopTransportControllerTest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace Tests\Unit\admin\Controllers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use admin\Controllers\ShopTransportController;
|
||||
use Domain\Transport\TransportRepository;
|
||||
use Domain\PaymentMethod\PaymentMethodRepository;
|
||||
|
||||
class ShopTransportControllerTest extends TestCase
|
||||
{
|
||||
private $transportRepository;
|
||||
private $paymentMethodRepository;
|
||||
private $controller;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->transportRepository = $this->createMock(TransportRepository::class);
|
||||
$this->paymentMethodRepository = $this->createMock(PaymentMethodRepository::class);
|
||||
$this->controller = new ShopTransportController(
|
||||
$this->transportRepository,
|
||||
$this->paymentMethodRepository
|
||||
);
|
||||
}
|
||||
|
||||
public function testConstructorAcceptsRepositories(): void
|
||||
{
|
||||
$controller = new ShopTransportController(
|
||||
$this->transportRepository,
|
||||
$this->paymentMethodRepository
|
||||
);
|
||||
$this->assertInstanceOf(ShopTransportController::class, $controller);
|
||||
}
|
||||
|
||||
public function testHasMainActionMethods(): void
|
||||
{
|
||||
$this->assertTrue(method_exists($this->controller, 'list'));
|
||||
$this->assertTrue(method_exists($this->controller, 'edit'));
|
||||
$this->assertTrue(method_exists($this->controller, 'save'));
|
||||
}
|
||||
|
||||
public function testHasNoLegacyAliasMethods(): void
|
||||
{
|
||||
$this->assertFalse(method_exists($this->controller, 'view_list'));
|
||||
$this->assertFalse(method_exists($this->controller, 'transport_edit'));
|
||||
$this->assertFalse(method_exists($this->controller, 'transport_save'));
|
||||
}
|
||||
|
||||
public function testActionMethodReturnTypes(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->controller);
|
||||
|
||||
$this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType());
|
||||
$this->assertEquals('string', (string)$reflection->getMethod('edit')->getReturnType());
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType());
|
||||
}
|
||||
|
||||
public function testConstructorRequiresBothRepositories(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(ShopTransportController::class);
|
||||
$constructor = $reflection->getConstructor();
|
||||
$params = $constructor->getParameters();
|
||||
|
||||
$this->assertCount(2, $params);
|
||||
$this->assertEquals('Domain\Transport\TransportRepository', $params[0]->getType()->getName());
|
||||
$this->assertEquals('Domain\PaymentMethod\PaymentMethodRepository', $params[1]->getType()->getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user