sarga/tests/unit/Checkout/Cart/Controllers/CartControllerCest.php

52 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Unit\Checkout\Cart\Controllers;
use UnitTester;
2020-02-04 17:13:09 +00:00
use Codeception\Example;
use Webkul\Checkout\Models\Cart;
use Webkul\Shop\Http\Controllers\CartController;
class CartControllerCest
{
2020-02-04 17:13:09 +00:00
/**
* @param \UnitTester $I
*
* @param \Example $scenario
*
* @throws \Exception
2020-06-04 11:25:12 +00:00
* @dataProvider getOnFailureAddingToCartScenarios
2020-02-04 17:13:09 +00:00
*/
2020-06-04 11:25:12 +00:00
public function testOnFailureAddingToCart(UnitTester $I, Example $scenario): void
{
2020-02-04 17:13:09 +00:00
$I->assertEquals($scenario['expected'],
$I->executeFunction(
CartController::class,
2020-06-04 11:25:12 +00:00
'onFailureAddingToCart',
2020-02-04 17:13:09 +00:00
[$scenario['result']]
)
);
}
2020-06-04 11:25:12 +00:00
protected function getOnFailureAddingToCartScenarios(): array
{
2020-02-04 17:13:09 +00:00
return [
[
2020-02-04 17:13:09 +00:00
'result' => ['key' => 'value', 'warning' => 'Hello World. Something went wrong.'],
'expected' => true,
],
2020-06-04 11:25:12 +00:00
[
'result' => ['key' => 'value', 'info' => 'This is only a test.'],
'expected' => true,
],
[
2020-02-04 17:13:09 +00:00
'result' => ['key' => 'value'],
'expected' => false,
],
[
2020-02-04 17:13:09 +00:00
'result' => new Cart(),
'expected' => false,
],
];
}
}