Release 0.265: ShopPromotion date_from and edit save fix
This commit is contained in:
53
tests/Unit/admin/Controllers/ShopPromotionControllerTest.php
Normal file
53
tests/Unit/admin/Controllers/ShopPromotionControllerTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace Tests\Unit\admin\Controllers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use admin\Controllers\ShopPromotionController;
|
||||
use Domain\Promotion\PromotionRepository;
|
||||
|
||||
class ShopPromotionControllerTest extends TestCase
|
||||
{
|
||||
private $repository;
|
||||
private $controller;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repository = $this->createMock(PromotionRepository::class);
|
||||
$this->controller = new ShopPromotionController($this->repository);
|
||||
}
|
||||
|
||||
public function testConstructorAcceptsRepository(): void
|
||||
{
|
||||
$controller = new ShopPromotionController($this->repository);
|
||||
$this->assertInstanceOf(ShopPromotionController::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'));
|
||||
$this->assertTrue(method_exists($this->controller, 'delete'));
|
||||
}
|
||||
|
||||
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());
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('delete')->getReturnType());
|
||||
}
|
||||
|
||||
public function testConstructorRequiresPromotionRepository(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(ShopPromotionController::class);
|
||||
$constructor = $reflection->getConstructor();
|
||||
$params = $constructor->getParameters();
|
||||
|
||||
$this->assertCount(1, $params);
|
||||
$this->assertEquals('Domain\Promotion\PromotionRepository', $params[0]->getType()->getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user