coming along
This commit is contained in:
@@ -62,16 +62,19 @@ class CartItemsControllerTest extends TestCase
|
||||
$beforeCnt = $this->CartItems->find()->where(['foreign_key_uuid' => $skuId])->count();
|
||||
$postData = [
|
||||
'foreign_key' => null,
|
||||
'foreign_key_uuid' => '3a477e3e-7977-4813-81f6-f85949613979',
|
||||
'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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +85,28 @@ class CartItemsControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
$this->markTestIncomplete('Not implemented yet.');
|
||||
$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';
|
||||
|
||||
$postData = [
|
||||
'qty' => 100,
|
||||
];
|
||||
$this->post($url, $postData);
|
||||
$this->assertResponseCode(302);
|
||||
|
||||
$new = $this->CartItems->get($id);
|
||||
$this->assertEquals(100, $new->qty);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user