sarga/tests/unit/Core/Commands/BookingCronCest.php

56 lines
1.7 KiB
PHP
Raw Normal View History

bagisto master backmerge (#26) * introduce cronjob to automatically deactivate expired events * remove irrelevant code * extend cart rule validation with search in cart item additional * add additional to all languages * add ValidatorCest * add ValidatorCest * Fixed case sensitivity typo in Bundle class * Update 503.blade.php * Added customer group price * Fixed bundle type class compatablity issue * Refactor some changes Co-authored-by: Florian Bosdorff <26360670+bosix@users.noreply.github.com> * add english translation to foreign languages * fix compatibility issue to AbstractType * check if product_id exists * make a prefix to the copied cart rule ('copy of XXX') and properly save related channels and customer groups after replication * add table, lists, link and hr functionality to editor * Issue #3164 fixed * Turkish Language added and English language duplicate rows deleted. * Turkish Language added and English language duplicate rows deleted. * Turkish Language added and English language duplicate rows deleted. * Issue #3113 fixed * fix tiny issues due to code guidelines * add default value for search term * fix typo * Fixed typo in customer group price migration * Issue #3171 fixed * Issue #3070 fixed * minified jquery-ez-plus file * Issue #3160 fixed Co-authored-by: Shubham Mehrotra <shubh0896m@gmail.com> Co-authored-by: Matt April <matthew.japril@gmail.com> Co-authored-by: bhumikaisarani <63963172+bhumikaisarani@users.noreply.github.com> Co-authored-by: Jitendra Singh <39991107+jitendra-webkul@users.noreply.github.com> Co-authored-by: Pranshu Tomar <pranshutomar@Pranshus-MacBook-Air.local> Co-authored-by: Florian Bosdorff <26360670+bosix@users.noreply.github.com> Co-authored-by: Herbert Maschke <thyseus@pm.me> Co-authored-by: phillipmohr <phillip.mohr@sellerboost.de> Co-authored-by: İlyas Okay <ilyasokay@hotmail.com> Co-authored-by: Florian Bosdorff <florian.bosdorff@haendlerbund.de> Co-authored-by: phillipcodes <57101430+phillipcodes@users.noreply.github.com>
2020-06-09 05:55:56 +00:00
<?php
namespace Tests\Unit\Core\Commands;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use UnitTester;
use Webkul\BookingProduct\Models\BookingProduct;
use Webkul\BookingProduct\Models\BookingProductEventTicket;
use Webkul\Core\Helpers\Laravel5Helper;
use Webkul\Product\Models\Product;
class BookingCronCest
{
public function testBookingCronDeactivateSomeEvents(UnitTester $I): void
{
$index = $I->fake()->numberBetween(2, 6);
for ($i=0; $i<$index; $i++) {
$products[$i] = $I->haveProduct(Laravel5Helper::VIRTUAL_PRODUCT);
Product::query()->where('id', $products[$i]->id)->update(['type' => 'booking']);
if ($I->fake()->randomDigitNotNull <= 5) {
$availableTo = Carbon::now()->subMinutes($I->fake()->numberBetween(2, 59));
} else {
$availableTo = Carbon::now()->addMinutes($I->fake()->numberBetween(2, 59));
}
$bookingProducts[$i] = $I->have(BookingProduct::class, [
'type' => 'event',
'available_to' => $availableTo->toDateTimeString(),
'product_id' => $products[$i]->id,
]);
$I->have(BookingProductEventTicket::class,
['booking_product_id' => $bookingProducts[$i]->id]);
$products[$i]->refresh();
$I->assertNotFalse($products[$i]->status);
}
$I->callArtisan('booking:cron');
for ($i=0; $i<$index; $i++) {
$products[$i]->refresh();
if ($bookingProducts[$i]->available_to < Carbon::now()) {
$I->assertEquals(0, $products[$i]->status);
} else {
$I->assertEquals(1, $products[$i]->status);
}
}
}
}