ver. 0.269: ShopPaymentMethod refactor + Apilo keepalive
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace Tests\Unit\admin\Controllers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use admin\Controllers\ShopPaymentMethodController;
|
||||
use Domain\PaymentMethod\PaymentMethodRepository;
|
||||
|
||||
class ShopPaymentMethodControllerTest extends TestCase
|
||||
{
|
||||
private $repository;
|
||||
private $controller;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repository = $this->createMock(PaymentMethodRepository::class);
|
||||
$this->controller = new ShopPaymentMethodController($this->repository);
|
||||
}
|
||||
|
||||
public function testConstructorAcceptsRepository(): void
|
||||
{
|
||||
$controller = new ShopPaymentMethodController($this->repository);
|
||||
$this->assertInstanceOf(ShopPaymentMethodController::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, 'payment_method_edit'));
|
||||
$this->assertFalse(method_exists($this->controller, 'payment_method_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 testConstructorRequiresPaymentMethodRepository(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(ShopPaymentMethodController::class);
|
||||
$constructor = $reflection->getConstructor();
|
||||
$params = $constructor->getParameters();
|
||||
|
||||
$this->assertCount(1, $params);
|
||||
$this->assertEquals('Domain\PaymentMethod\PaymentMethodRepository', $params[0]->getType()->getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user