first test passing
This commit is contained in:
@@ -6,6 +6,8 @@ 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
|
||||
@@ -16,6 +18,13 @@ class CartItemsControllerTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
|
||||
/**
|
||||
* Test subject
|
||||
*
|
||||
* @var \CakeCarts\Model\Table\CartItemsTable
|
||||
*/
|
||||
protected $CartItems;
|
||||
|
||||
/**
|
||||
* Fixtures
|
||||
*
|
||||
@@ -26,27 +35,14 @@ class CartItemsControllerTest extends TestCase
|
||||
'plugin.CakeCarts.Carts',
|
||||
];
|
||||
|
||||
/**
|
||||
* Test index method
|
||||
*
|
||||
* @return void
|
||||
* @link \CakeCarts\Controller\CartItemsController::index()
|
||||
*/
|
||||
public function testIndex(): void
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
$config = $this->getTableLocator()->exists('CartItems') ? [] : ['className' => CartItemsTable::class];
|
||||
$this->CartItems = $this->getTableLocator()->get('CartItems', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test view method
|
||||
*
|
||||
* @return void
|
||||
* @link \CakeCarts\Controller\CartItemsController::view()
|
||||
*/
|
||||
public function testView(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add method
|
||||
@@ -56,7 +52,26 @@ class CartItemsControllerTest extends TestCase
|
||||
*/
|
||||
public function testAdd(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
$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' => '3a477e3e-7977-4813-81f6-f85949613979',
|
||||
'model' => 'ProductSkus',
|
||||
'qty' => 10,
|
||||
'price' => 0.75,
|
||||
];
|
||||
$this->post($url, $postData);
|
||||
$this->assertResponseCode(302);
|
||||
$afterCnt = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId])->count();
|
||||
|
||||
$this->assertEquals($beforeCnt + 1, $afterCnt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
1
tests/config/bootstrap.php
Normal file
1
tests/config/bootstrap.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
||||
1
tests/config/routes.php
Normal file
1
tests/config/routes.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
||||
Reference in New Issue
Block a user