phpcbf and added .gitea workflows
This commit is contained in:
@@ -5,118 +5,115 @@ namespace CakeCarts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeCarts\Controller\CartItemsController;
|
||||
use CakeCarts\Model\Table\CartItemsTable;
|
||||
use CakeCarts\Model\Table\CartsTable;
|
||||
|
||||
/**
|
||||
* CakeCarts\Controller\CartItemsController Test Case
|
||||
*
|
||||
* @link \CakeCarts\Controller\CartItemsController
|
||||
*/
|
||||
class CartItemsControllerTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
class CartItemsControllerTest extends TestCase {
|
||||
|
||||
/**
|
||||
use IntegrationTestTrait;
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeCarts\Model\Table\CartItemsTable
|
||||
*/
|
||||
protected $CartItems;
|
||||
protected $CartItems;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeCarts.CartItems',
|
||||
'plugin.CakeCarts.Carts',
|
||||
];
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeCarts.CartItems',
|
||||
'plugin.CakeCarts.Carts',
|
||||
];
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp(): void {
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
$config = $this->getTableLocator()->exists('CartItems') ? [] : ['className' => CartItemsTable::class];
|
||||
$this->CartItems = $this->getTableLocator()->get('CartItems', $config);
|
||||
}
|
||||
$config = $this->getTableLocator()->exists('CartItems') ? [] : ['className' => CartItemsTable::class];
|
||||
$this->CartItems = $this->getTableLocator()->get('CartItems', $config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test add method
|
||||
*
|
||||
* @return void
|
||||
* @link \CakeCarts\Controller\CartItemsController::add()
|
||||
* @return void
|
||||
*/
|
||||
public function testAdd(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeCarts',
|
||||
'controller' => 'CartItems',
|
||||
'action' => 'add',
|
||||
];
|
||||
$skuId = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
public function testAdd(): void {
|
||||
$url = [
|
||||
'plugin' => 'CakeCarts',
|
||||
'controller' => 'CartItems',
|
||||
'action' => 'add',
|
||||
];
|
||||
$skuId = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
|
||||
$beforeCnt = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId])->count();
|
||||
$postData = [
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => $skuId,
|
||||
'model' => 'ProductSkus',
|
||||
'qty' => 10,
|
||||
'price' => 0.75,
|
||||
'subtotal' => 1,
|
||||
];
|
||||
$this->post($url, $postData);
|
||||
$this->assertResponseCode(302);
|
||||
$afterCnt = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId])->count();
|
||||
$this->assertEquals($beforeCnt + 1, $afterCnt);
|
||||
$beforeCnt = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId])->count();
|
||||
$postData = [
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => $skuId,
|
||||
'model' => 'ProductSkus',
|
||||
'qty' => 10,
|
||||
'price' => 0.75,
|
||||
'subtotal' => 1,
|
||||
];
|
||||
$this->post($url, $postData);
|
||||
$this->assertResponseCode(302);
|
||||
$afterCnt = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId])->count();
|
||||
$this->assertEquals($beforeCnt + 1, $afterCnt);
|
||||
|
||||
$new = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId, 'qty' => 10, 'model' => 'ProductSkus'])->firstOrFail();
|
||||
$this->assertEquals(7.5, $new->subtotal);
|
||||
}
|
||||
$new = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId, 'qty' => 10, 'model' => 'ProductSkus'])->firstOrFail();
|
||||
$this->assertEquals(7.5, $new->subtotal);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test edit method
|
||||
*
|
||||
* @return void
|
||||
* @link \CakeCarts\Controller\CartItemsController::edit()
|
||||
* @return void
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
$id = '79f66e8d-8d8d-4095-adc4-fd15234a4397';
|
||||
$url = [
|
||||
'plugin' => 'CakeCarts',
|
||||
'controller' => 'CartItems',
|
||||
'action' => 'edit',
|
||||
$id
|
||||
];
|
||||
$this->session(['Auth.User.id' => 1]);
|
||||
$this->session(['Auth.id' => 1]);
|
||||
$this->session(['CakeCarts.session_id' => 'session_1']);
|
||||
$before = $this->CartItems->get($id, contain: ['Carts']);
|
||||
public function testEdit(): void {
|
||||
$id = '79f66e8d-8d8d-4095-adc4-fd15234a4397';
|
||||
$url = [
|
||||
'plugin' => 'CakeCarts',
|
||||
'controller' => 'CartItems',
|
||||
'action' => 'edit',
|
||||
$id,
|
||||
];
|
||||
$this->session(['Auth.User.id' => 1]);
|
||||
$this->session(['Auth.id' => 1]);
|
||||
$this->session(['CakeCarts.session_id' => 'session_1']);
|
||||
$before = $this->CartItems->get($id, contain: ['Carts']);
|
||||
// dd($before);
|
||||
$skuId = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
$skuId = '3a477e3e-7977-4813-81f6-f85949613979';
|
||||
|
||||
$postData = [
|
||||
'qty' => 100,
|
||||
];
|
||||
$this->post($url, $postData);
|
||||
$this->assertResponseCode(302);
|
||||
$postData = [
|
||||
'qty' => 100,
|
||||
];
|
||||
$this->post($url, $postData);
|
||||
$this->assertResponseCode(302);
|
||||
|
||||
$new = $this->CartItems->get($id);
|
||||
$this->assertEquals(100, $new->qty);
|
||||
}
|
||||
$new = $this->CartItems->get($id);
|
||||
$this->assertEquals(100, $new->qty);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test delete method
|
||||
*
|
||||
* @return void
|
||||
* @link \CakeCarts\Controller\CartItemsController::delete()
|
||||
* @return void
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
public function testDelete(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,41 +5,45 @@ namespace CakeCarts\Test\TestCase\Controller;
|
||||
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use CakeCarts\Controller\CartsController;
|
||||
|
||||
/**
|
||||
* CakeCarts\Controller\CartsController Test Case
|
||||
*
|
||||
* @uses \CakeCarts\Controller\CartsController
|
||||
*/
|
||||
class CartsControllerTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
class CartsControllerTest extends TestCase {
|
||||
|
||||
/**
|
||||
use IntegrationTestTrait;
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeCarts\Model\Table\CartItemsTable
|
||||
*/
|
||||
protected $Carts;
|
||||
protected $Carts;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUp(): void {
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
$config = $this->getTableLocator()->exists('Carts') ? [] : ['className' => CartsTable::class];
|
||||
$this->Carts = $this->getTableLocator()->get('Carts', $config);
|
||||
}
|
||||
$config = $this->getTableLocator()->exists('Carts') ? [] : ['className' => CartsTable::class];
|
||||
$this->Carts = $this->getTableLocator()->get('Carts', $config);
|
||||
}
|
||||
|
||||
public function testIndex(): void
|
||||
{
|
||||
$url = [
|
||||
'plugin' => 'CakeCarts',
|
||||
'controller' => 'Carts',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testIndex(): void {
|
||||
$url = [
|
||||
'plugin' => 'CakeCarts',
|
||||
'controller' => 'Carts',
|
||||
'action' => 'index',
|
||||
];
|
||||
$this->get($url);
|
||||
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
|
||||
$this->assertResponseCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,36 +10,35 @@ use CakeCarts\Controller\Component\ShoppingCartComponent;
|
||||
/**
|
||||
* CakeCarts\Controller\Component\ShoppingCartComponent Test Case
|
||||
*/
|
||||
class ShoppingCartComponentTest extends TestCase
|
||||
{
|
||||
/**
|
||||
class ShoppingCartComponentTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeCarts\Controller\Component\ShoppingCartComponent
|
||||
*/
|
||||
protected $ShoppingCart;
|
||||
protected $ShoppingCart;
|
||||
|
||||
/**
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$registry = new ComponentRegistry();
|
||||
$this->ShoppingCart = new ShoppingCartComponent($registry);
|
||||
}
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$registry = new ComponentRegistry();
|
||||
$this->ShoppingCart = new ShoppingCartComponent($registry);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->ShoppingCart);
|
||||
protected function tearDown(): void {
|
||||
unset($this->ShoppingCart);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user