Skip to content

Commit

Permalink
Merge pull request #93 from BitBagCommerce/release/20230707
Browse files Browse the repository at this point in the history
Release 20230707
  • Loading branch information
senghe authored Jul 13, 2023
2 parents fe5f3df + 343a11d commit 90879bc
Show file tree
Hide file tree
Showing 122 changed files with 5,753 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"license": "MIT",
"require": {
"php": "^8.0",
"ext-intl": "*",
"ext-json": "*",
"ext-openssl": "*",
"bitbag/wishlist-plugin": "^3.0",
Expand Down
81 changes: 81 additions & 0 deletions spec/Controller/ThankYouPageControllerSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

declare(strict_types=1);

namespace spec\BitBag\SyliusVueStorefront2Plugin\Controller;

use BitBag\SyliusVueStorefront2Plugin\Controller\ThankYouPageController;
use PhpSpec\ObjectBehavior;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouterInterface;

final class ThankYouPageControllerSpec extends ObjectBehavior
{
private const VSF2_HOST = 'http://localhost/';

public function let(RouterInterface $router): void
{
$this->beConstructedWith(self::VSF2_HOST, $router);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(ThankYouPageController::class);
}

public function it_redirects_to_homepage_if_host_not_provided(
RouterInterface $router,
Request $request,
): void {
$this->beConstructedWith(null, $router);

$url = '/en_US/';
$router->generate('sylius_shop_homepage')->willReturn($url);

$response = $this->redirectAction($request);

$response->shouldBeAnInstanceOf(RedirectResponse::class);
$response->getTargetUrl()->shouldReturn($url);
}

public function it_redirects_to_homepage_if_order_number_is_not_provided(
RouterInterface $router,
): void {
$attributes = [];
$request = new Request([], [], $attributes);

$url = '/en_US/';
$router->generate('sylius_shop_homepage')->willReturn($url);

$response = $this->redirectAction($request);

$response->shouldBeAnInstanceOf(RedirectResponse::class);
$response->getTargetUrl()->shouldReturn($url);
}

function it_redirects_to_thank_you_page(): void
{
$locale = 'de_DE';
$orderNumber = '123';
$request = new Request(['locale' => $locale], [], ['orderNumber' => $orderNumber]);

$url = sprintf(
'%s/%s/checkout/thank-you?order=%s',
self::VSF2_HOST,
locale_get_primary_language($locale),
$orderNumber
);

$response = $this->redirectAction($request);

$response->shouldBeAnInstanceOf(RedirectResponse::class);
$response->getTargetUrl()->shouldReturn($url);
}
}
108 changes: 108 additions & 0 deletions spec/DataGenerator/ContextModel/DataGeneratorCommandContextSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

declare(strict_types=1);

namespace spec\BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel;

use BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\DataGeneratorCommandContext;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

final class DataGeneratorCommandContextSpec extends ObjectBehavior
{
private const PRODUCTS_QTY = 100;

private const TAXONS_QTY = 200;

private const WISHLISTS_QTY = 300;

private const PRODUCTS_PER_TAXON_QTY = 400;

private const MAX_TAXON_LEVEL = 500;

private const MAX_CHILDREN_PER_TAXON_LEVEL = 600;

private const PRODUCTS_PER_WISHLIST_QTY = 700;

private const STRESS = 25;

public function let(
SymfonyStyle $io,
ChannelInterface $channel,
): void {
$this->beConstructedWith(
$io,
$channel,
self::PRODUCTS_QTY,
self::TAXONS_QTY,
self::WISHLISTS_QTY,
self::PRODUCTS_PER_TAXON_QTY,
self::MAX_TAXON_LEVEL,
self::MAX_CHILDREN_PER_TAXON_LEVEL,
self::PRODUCTS_PER_WISHLIST_QTY,
self::STRESS,
);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(DataGeneratorCommandContext::class);
}

public function it_returns_io(SymfonyStyle $io): void
{
$this->getIO()->shouldReturn($io);
}

public function it_returns_channel(ChannelInterface $channel): void
{
$this->getChannel()->shouldReturn($channel);
}

public function it_returns_products_qty(): void
{
$this->getProductsQty()->shouldReturn(self::PRODUCTS_QTY);
}

public function it_returns_taxons_qty(): void
{
$this->getTaxonsQty()->shouldReturn(self::TAXONS_QTY);
}

public function it_returns_wishlists_qty(): void
{
$this->getWishlistsQty()->shouldReturn(self::WISHLISTS_QTY);
}

public function it_returns_products_per_taxon_qty(): void
{
$this->getProductsPerTaxonQty()->shouldReturn(self::PRODUCTS_PER_TAXON_QTY);
}

public function it_returns_max_taxon_level(): void
{
$this->getMaxTaxonLevel()->shouldReturn(self::MAX_TAXON_LEVEL);
}

public function it_returns_max_children_per_taxon_level(): void
{
$this->getMaxChildrenPerTaxonLevel()->shouldReturn(self::MAX_CHILDREN_PER_TAXON_LEVEL);
}

public function it_returns_products_per_wishlist_qty(): void
{
$this->getProductsPerWishlistQty()->shouldReturn(self::PRODUCTS_PER_WISHLIST_QTY);
}

public function it_returns_stress(): void
{
$this->getStress()->shouldReturn(self::STRESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

declare(strict_types=1);

namespace spec\BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\Generator;

use BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\Generator\ProductGeneratorContext;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

final class ProductGeneratorContextSpec extends ObjectBehavior
{
private const QUANTITY = 100;

public function let(
SymfonyStyle $io,
ChannelInterface $channel,
): void {
$this->beConstructedWith(
$io,
self::QUANTITY,
$channel,
);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(ProductGeneratorContext::class);
}

public function it_returns_io(SymfonyStyle $io): void
{
$this->getIo()->shouldReturn($io);
}

public function it_returns_quantity(): void
{
$this->getQuantity()->shouldReturn(self::QUANTITY);
}

public function it_returns_channel(ChannelInterface $channel): void
{
$this->getChannel()->shouldReturn($channel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

declare(strict_types=1);

namespace spec\BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\Generator;

use BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\Generator\ProductTaxonGeneratorContext;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

final class ProductTaxonGeneratorContextSpec extends ObjectBehavior
{
private const QUANTITY = 100;

private const STRESS = 15;

public function let(
SymfonyStyle $io,
ChannelInterface $channel,
): void {
$this->beConstructedWith(
$io,
self::QUANTITY,
$channel,
self::STRESS,
);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(ProductTaxonGeneratorContext::class);
}

public function it_returns_io(SymfonyStyle $io): void
{
$this->getIo()->shouldReturn($io);
}

public function it_returns_quantity(): void
{
$this->getQuantity()->shouldReturn(self::QUANTITY);
}

public function it_returns_channel(ChannelInterface $channel): void
{
$this->getChannel()->shouldReturn($channel);
}

public function it_returns_stress(): void
{
$this->getStress()->shouldReturn(self::STRESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

declare(strict_types=1);

namespace spec\BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\Generator;

use BitBag\SyliusVueStorefront2Plugin\DataGenerator\ContextModel\Generator\TaxonGeneratorContext;
use PhpSpec\ObjectBehavior;
use Symfony\Component\Console\Style\SymfonyStyle;

final class TaxonGeneratorContextSpec extends ObjectBehavior
{
private const QUANTITY = 100;

private const MAX_TAXON_LEVEL = 10;

private const MAX_CHILDREN_PER_TAXON_LEVEL = 5;

public function let(SymfonyStyle $io): void
{
$this->beConstructedWith(
$io,
self::QUANTITY,
self::MAX_TAXON_LEVEL,
self::MAX_CHILDREN_PER_TAXON_LEVEL,
);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(TaxonGeneratorContext::class);
}

public function it_returns_io(SymfonyStyle $io): void
{
$this->getIo()->shouldReturn($io);
}

public function it_returns_quantity(): void
{
$this->getQuantity()->shouldReturn(self::QUANTITY);
}

public function it_returns_max_taxon_level(): void
{
$this->getMaxTaxonLevel()->shouldReturn(self::MAX_TAXON_LEVEL);
}

public function it_returns_max_children_per_taxon_level(): void
{
$this->getMaxChildrenPerTaxonLevel()->shouldReturn(self::MAX_CHILDREN_PER_TAXON_LEVEL);
}
}
Loading

0 comments on commit 90879bc

Please sign in to comment.