phpcbf and added .gitea workflows
This commit is contained in:
@@ -8,61 +8,61 @@ use Cake\TestSuite\Fixture\TestFixture;
|
||||
/**
|
||||
* CartItemsFixture
|
||||
*/
|
||||
class CartItemsFixture extends TestFixture
|
||||
{
|
||||
/**
|
||||
class CartItemsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '79f66e8d-8d8d-4095-adc4-fd15234a4397',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51ea',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-ba10-61e1190c51eb',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51eb',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e4190c51ec',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51ec',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
[
|
||||
'id' => '79f66e8d-8d8d-4095-adc4-fd15234a4394',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51ed',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
[
|
||||
'id' => '79f66e8d-8d8d-4095-adc4-fd15234a4397',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51ea',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-ba10-61e1190c51eb',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51eb',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e4190c51ec',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51ec',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
[
|
||||
'id' => '79f66e8d-8d8d-4095-adc4-fd15234a4394',
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => 'e5efe749-d6b6-4f72-83c9-32b19936c70c',
|
||||
'model' => 'ProductSkus',
|
||||
'cart_id' => '74d1aa54-92a2-4039-bc10-61e1190c51ed',
|
||||
'position' => 1,
|
||||
'qty' => 1,
|
||||
'price' => 1.5,
|
||||
'subtotal' => 1.5,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,73 +9,73 @@ use CakeCarts\Model\Enum\CartTypeId;
|
||||
/**
|
||||
* CartsFixture
|
||||
*/
|
||||
class CartsFixture extends TestFixture
|
||||
{
|
||||
/**
|
||||
class CartsFixture extends TestFixture {
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->records = [
|
||||
// normal cart - open
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51ea',
|
||||
'cart_type_id' => CartTypeId::Cart->value,
|
||||
'session_id' => 'session_1',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => null,
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
// normal cart - deleted
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51eb',
|
||||
'cart_type_id' => CartTypeId::Cart->value,
|
||||
'session_id' => 'session_1',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => '2025-10-08 09:55:15',
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
// wishlist cart - open
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51ec',
|
||||
'cart_type_id' => CartTypeId::Wishlist->value,
|
||||
'session_id' => 'session_2',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => null,
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
// wishlist cart - deleted
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51ed',
|
||||
'cart_type_id' => CartTypeId::Wishlist->value,
|
||||
'session_id' => 'session_2',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => '2025-10-08 09:55:15',
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
public function init(): void {
|
||||
$this->records = [
|
||||
// normal cart - open
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51ea',
|
||||
'cart_type_id' => CartTypeId::Cart->value,
|
||||
'session_id' => 'session_1',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => null,
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
// normal cart - deleted
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51eb',
|
||||
'cart_type_id' => CartTypeId::Cart->value,
|
||||
'session_id' => 'session_1',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => '2025-10-08 09:55:15',
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
// wishlist cart - open
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51ec',
|
||||
'cart_type_id' => CartTypeId::Wishlist->value,
|
||||
'session_id' => 'session_2',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => null,
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
// wishlist cart - deleted
|
||||
[
|
||||
'id' => '74d1aa54-92a2-4039-bc10-61e1190c51ed',
|
||||
'cart_type_id' => CartTypeId::Wishlist->value,
|
||||
'session_id' => 'session_2',
|
||||
'user_id' => null,
|
||||
'user_id_uuid' => '5a34a6ae-7d3f-4dcf-bac7-57335b51e697',
|
||||
'created' => '2025-10-08 09:55:15',
|
||||
'modified' => '2025-10-08 09:55:15',
|
||||
'deleted' => '2025-10-08 09:55:15',
|
||||
'removed' => null,
|
||||
'removed_reason_id' => null,
|
||||
'num_items' => 1,
|
||||
],
|
||||
];
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,68 +9,65 @@ use CakeCarts\Model\Table\CartItemsTable;
|
||||
/**
|
||||
* CakeCarts\Model\Table\CartItemsTable Test Case
|
||||
*/
|
||||
class CartItemsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
class CartItemsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeCarts\Model\Table\CartItemsTable
|
||||
*/
|
||||
protected $CartItems;
|
||||
protected $CartItems;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeCarts.CartItems',
|
||||
'plugin.CakeCarts.Carts',
|
||||
];
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeCarts.CartItems',
|
||||
'plugin.CakeCarts.Carts',
|
||||
];
|
||||
|
||||
/**
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('CartItems') ? [] : ['className' => CartItemsTable::class];
|
||||
$this->CartItems = $this->getTableLocator()->get('CartItems', $config);
|
||||
}
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('CartItems') ? [] : ['className' => CartItemsTable::class];
|
||||
$this->CartItems = $this->getTableLocator()->get('CartItems', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->CartItems);
|
||||
protected function tearDown(): void {
|
||||
unset($this->CartItems);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeCarts\Model\Table\CartItemsTable::validationDefault()
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeCarts\Model\Table\CartItemsTable::buildRules()
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,69 +9,66 @@ use CakeCarts\Model\Table\CartsTable;
|
||||
/**
|
||||
* CakeCarts\Model\Table\CartsTable Test Case
|
||||
*/
|
||||
class CartsTableTest extends TestCase
|
||||
{
|
||||
/**
|
||||
class CartsTableTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeCarts\Model\Table\CartsTable
|
||||
*/
|
||||
protected $Carts;
|
||||
protected $Carts;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeCarts.Carts',
|
||||
protected array $fixtures = [
|
||||
'plugin.CakeCarts.Carts',
|
||||
// 'plugin.CakeCarts.Users',
|
||||
'plugin.CakeCarts.CartItems',
|
||||
];
|
||||
'plugin.CakeCarts.CartItems',
|
||||
];
|
||||
|
||||
/**
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Carts') ? [] : ['className' => CartsTable::class];
|
||||
$this->Carts = $this->getTableLocator()->get('Carts', $config);
|
||||
}
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$config = $this->getTableLocator()->exists('Carts') ? [] : ['className' => CartsTable::class];
|
||||
$this->Carts = $this->getTableLocator()->get('Carts', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->Carts);
|
||||
protected function tearDown(): void {
|
||||
unset($this->Carts);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test validationDefault method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeCarts\Model\Table\CartsTable::validationDefault()
|
||||
* @return void
|
||||
*/
|
||||
public function testValidationDefault(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
public function testValidationDefault(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Test buildRules method
|
||||
*
|
||||
* @return void
|
||||
* @uses \CakeCarts\Model\Table\CartsTable::buildRules()
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildRules(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
public function testBuildRules(): void {
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,20 +7,19 @@ use Cake\Core\Configure;
|
||||
use Cake\Core\Plugin;
|
||||
use Cake\Database\Connection;
|
||||
use Cake\Datasource\ConnectionManager;
|
||||
use Cake\TestSuite\Fixture\SchemaLoader;
|
||||
use CakeProducts\CakeProductsPlugin;
|
||||
use CakeCarts\CakeCartsPlugin;
|
||||
use Migrations\TestSuite\Migrator;
|
||||
use TestApp\Controller\AppController;
|
||||
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
if (!defined('WINDOWS')) {
|
||||
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
|
||||
define('WINDOWS', true);
|
||||
} else {
|
||||
define('WINDOWS', false);
|
||||
}
|
||||
if (DS === '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
|
||||
define('WINDOWS', true);
|
||||
} else {
|
||||
define('WINDOWS', false);
|
||||
}
|
||||
}
|
||||
|
||||
define('PLUGIN_ROOT', dirname(__DIR__));
|
||||
@@ -45,69 +44,69 @@ require CORE_PATH . 'config/bootstrap.php';
|
||||
require CAKE . 'functions.php';
|
||||
|
||||
Configure::write('App', [
|
||||
'namespace' => 'TestApp',
|
||||
'encoding' => 'UTF-8',
|
||||
'paths' => [
|
||||
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
|
||||
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
|
||||
'templates' => [
|
||||
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
|
||||
],
|
||||
],
|
||||
'namespace' => 'TestApp',
|
||||
'encoding' => 'UTF-8',
|
||||
'paths' => [
|
||||
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
|
||||
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
|
||||
'templates' => [
|
||||
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
Configure::write('debug', true);
|
||||
Configure::write('CakeCarts', [
|
||||
'Carts' => [
|
||||
'table' => 'CakeCarts.Carts',
|
||||
],
|
||||
'CartItems' => [
|
||||
'requirePricing' => false,
|
||||
],
|
||||
'Users' => [
|
||||
'user_id' => 'uuid', // integer or uuid
|
||||
],
|
||||
'Carts' => [
|
||||
'table' => 'CakeCarts.Carts',
|
||||
],
|
||||
'CartItems' => [
|
||||
'requirePricing' => false,
|
||||
],
|
||||
'Users' => [
|
||||
'user_id' => 'uuid', // integer or uuid
|
||||
],
|
||||
]);
|
||||
|
||||
$cache = [
|
||||
'default' => [
|
||||
'engine' => 'File',
|
||||
'path' => CACHE,
|
||||
],
|
||||
'_cake_translations_' => [
|
||||
'className' => 'File',
|
||||
'prefix' => 'crud_myapp_cake_core_',
|
||||
'path' => CACHE . 'persistent/',
|
||||
'serialize' => true,
|
||||
'duration' => '+10 seconds',
|
||||
],
|
||||
'_cake_model_' => [
|
||||
'className' => 'File',
|
||||
'prefix' => 'crud_my_app_cake_model_',
|
||||
'path' => CACHE . 'models/',
|
||||
'serialize' => 'File',
|
||||
'duration' => '+10 seconds',
|
||||
],
|
||||
'default' => [
|
||||
'engine' => 'File',
|
||||
'path' => CACHE,
|
||||
],
|
||||
'_cake_translations_' => [
|
||||
'className' => 'File',
|
||||
'prefix' => 'crud_myapp_cake_core_',
|
||||
'path' => CACHE . 'persistent/',
|
||||
'serialize' => true,
|
||||
'duration' => '+10 seconds',
|
||||
],
|
||||
'_cake_model_' => [
|
||||
'className' => 'File',
|
||||
'prefix' => 'crud_my_app_cake_model_',
|
||||
'path' => CACHE . 'models/',
|
||||
'serialize' => 'File',
|
||||
'duration' => '+10 seconds',
|
||||
],
|
||||
];
|
||||
|
||||
Cache::setConfig($cache);
|
||||
|
||||
class_alias(AppController::class, 'App\Controller\AppController');
|
||||
|
||||
Plugin::getCollection()->add(new \CakeCarts\CakeCartsPlugin());
|
||||
Plugin::getCollection()->add(new CakeCartsPlugin());
|
||||
|
||||
Chronos::setTestNow(Chronos::now());
|
||||
|
||||
if (!getenv('DB_URL')) {
|
||||
putenv('DB_URL=sqlite:///:memory:');
|
||||
putenv('DB_URL=sqlite:///:memory:');
|
||||
}
|
||||
|
||||
ConnectionManager::setConfig('test', [
|
||||
'className' => Connection::class,
|
||||
'url' => getenv('DB_URL') ?: null,
|
||||
'timezone' => 'UTC',
|
||||
'quoteIdentifiers' => false,
|
||||
'cacheMetadata' => true,
|
||||
'className' => Connection::class,
|
||||
'url' => getenv('DB_URL') ?: null,
|
||||
'timezone' => 'UTC',
|
||||
'quoteIdentifiers' => false,
|
||||
'cacheMetadata' => true,
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user