diff --git a/packages/Webkul/BookingProduct/src/Database/Factories/BookingProductEventTicketFactory.php b/packages/Webkul/BookingProduct/src/Database/Factories/BookingProductEventTicketFactory.php index 09f79b311..608dd477d 100644 --- a/packages/Webkul/BookingProduct/src/Database/Factories/BookingProductEventTicketFactory.php +++ b/packages/Webkul/BookingProduct/src/Database/Factories/BookingProductEventTicketFactory.php @@ -2,16 +2,14 @@ /** @var \Illuminate\Database\Eloquent\Factory $factory */ -use Carbon\Carbon; use Faker\Generator as Faker; use Webkul\BookingProduct\Models\BookingProduct; use Webkul\BookingProduct\Models\BookingProductEventTicket; -use Webkul\Product\Models\Product; -$factory->define(BookingProductEventTicket::class, function (Faker $faker, array $attributes) { +$factory->define(BookingProductEventTicket::class, static function (Faker $faker, array $attributes) { return [ 'price' => $faker->randomFloat(4, 3, 900), - 'qty' => $faker->randomNumber(2), + 'qty' => $faker->numberBetween(100, 1000), 'booking_product_id' => static function () { return factory(BookingProduct::class)->create(['type' => 'event'])->id; } diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index f4788d481..6d1e1f8b0 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -126,4 +126,13 @@ class FunctionalTester extends \Codeception\Actor } } } + + public function useDefaultTheme(): void + { + $channel = core()->getCurrentChannel(); + + if ($channel->theme !== 'default') { + $channel->update(['theme' => 'default']); + } + } } diff --git a/tests/functional/Checkout/Cart/CartCest.php b/tests/functional/Checkout/Cart/CartCest.php index db20d49f0..0a4e5890b 100644 --- a/tests/functional/Checkout/Cart/CartCest.php +++ b/tests/functional/Checkout/Cart/CartCest.php @@ -4,7 +4,6 @@ namespace Tests\Functional\Checkout\Cart; use FunctionalTester; use Webkul\Core\Helpers\Laravel5Helper; -use Cart; class CartCest { @@ -12,7 +11,7 @@ class CartCest public $productWithQuantityBox; public $productWithoutQuantityBox; - public function _before(FunctionalTester $I) + public function _before(FunctionalTester $I): void { $productConfig = [ 'productAttributes' => [], @@ -27,9 +26,11 @@ class CartCest $this->productWithoutQuantityBox = $I->haveProduct(Laravel5Helper::DOWNLOADABLE_PRODUCT, $productConfig); } - public function checkCartWithQuantityBox(FunctionalTester $I) + public function checkCartWithQuantityBox(FunctionalTester $I): void { - Cart::addProduct($this->productWithQuantityBox->id, [ + $I->useDefaultTheme(); + + cart()->addProduct($this->productWithQuantityBox->id, [ '_token' => session('_token'), 'product_id' => $this->productWithQuantityBox->id, 'quantity' => 1, @@ -39,9 +40,9 @@ class CartCest $I->seeElement('#update_cart_button'); } - public function checkCartWithoutQuantityBox(FunctionalTester $I) + public function checkCartWithoutQuantityBox(FunctionalTester $I): void { - Cart::addProduct($this->productWithoutQuantityBox->id, [ + cart()->addProduct($this->productWithoutQuantityBox->id, [ '_token' => session('_token'), 'product_id' => $this->productWithoutQuantityBox->id, 'links' => $this->productWithoutQuantityBox->downloadable_links->pluck('id')->all(), diff --git a/tests/functional/Customer/CustomerCest.php b/tests/functional/Customer/CustomerCest.php index 49978ee64..3d5fecfac 100644 --- a/tests/functional/Customer/CustomerCest.php +++ b/tests/functional/Customer/CustomerCest.php @@ -2,6 +2,7 @@ namespace Tests\Functional\Customer; +use Faker\Factory; use Webkul\Customer\Models\Customer; use Webkul\Customer\Models\CustomerAddress; use FunctionalTester; @@ -10,6 +11,11 @@ class CustomerCest { public $fields = []; + public function _before(FunctionalTester $I): void + { + $I->useDefaultTheme(); + } + public function updateCustomerProfile(FunctionalTester $I): void { $customer = $I->loginAsCustomer(); @@ -32,8 +38,8 @@ class CustomerCest public function updateCustomerAddress(FunctionalTester $I): void { - $I->wantTo('Instantiate a european faker factory to have the vat provider available'); - $faker = \Faker\Factory::create('at_AT'); + // Instantiate a european faker factory to have the vat provider available + $faker = Factory::create('at_AT'); $formCssSelector = '#customer-address-form'; diff --git a/tests/functional/Shop/GuestCheckoutCest.php b/tests/functional/Shop/GuestCheckoutCest.php index 5a69f08f7..f9865527a 100644 --- a/tests/functional/Shop/GuestCheckoutCest.php +++ b/tests/functional/Shop/GuestCheckoutCest.php @@ -10,16 +10,16 @@ use Webkul\Core\Helpers\Laravel5Helper; class GuestCheckoutCest { - private $faker, - $productNoGuestCheckout, $productGuestCheckout; + private $productNoGuestCheckout, $productGuestCheckout; function _before(FunctionalTester $I) { + $I->useDefaultTheme(); - $this->faker = Factory::create(); + $faker = Factory::create(); $pConfigDefault = [ - 'productInventory' => ['qty' => $this->faker->numberBetween(1, 1000)], + 'productInventory' => ['qty' => $faker->numberBetween(1, 1000)], 'attributeValues' => [ 'status' => true, 'new' => 1, @@ -27,7 +27,7 @@ class GuestCheckoutCest ], ]; $pConfigGuestCheckout = [ - 'productInventory' => ['qty' => $this->faker->numberBetween(1, 1000)], + 'productInventory' => ['qty' => $faker->numberBetween(1, 1000)], 'attributeValues' => [ 'status' => true, 'new' => 1, @@ -72,8 +72,8 @@ class GuestCheckoutCest $I->click(__('shop::app.checkout.cart.proceed-to-checkout'), '//a[@href="' . route('shop.checkout.onepage.index') . '"]'); $I->seeCurrentRouteIs($example['expectedRoute']); - $cart = Cart::getCart(); - $I->assertTrue(Cart::removeItem($cart->items[0]->id)); + $cart = cart()->getCart(); + $I->assertTrue(cart()->removeItem($cart->items[0]->id)); } protected function guestCheckoutProvider(): array