-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Opsrc 397/export selected to pdf complete (#93)
* Add controller to generate pdf & create button for email
- Loading branch information
1 parent
6daa1b2
commit 44aa55f
Showing
43 changed files
with
975 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@wishlist | ||
Feature: Exporting a product from wishlist to pdf | ||
In order to save products and buy later | ||
As a Visitor | ||
I want to be able to exporting products to pdf | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
|
||
@ui | ||
Scenario: Exporting selected products from wishlist | ||
Given the store has a product "Jack Daniels Gentleman" priced at "$10.00" | ||
And I have this product in my wishlist | ||
When I go to the wishlist page | ||
Then I check "Jack Daniels Gentleman" | ||
And I export to pdf selected products from wishlist and file is downloaded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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\SyliusWishlistPlugin\Model\Factory; | ||
|
||
use BitBag\SyliusWishlistPlugin\Model\Factory\VariantPdfModelFactory; | ||
use BitBag\SyliusWishlistPlugin\Model\Factory\VariantPdfModelFactoryInterface; | ||
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModel; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\ProductVariant; | ||
|
||
final class VariantPdfModelFactorySpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(VariantPdfModelFactory::class); | ||
} | ||
|
||
function it_implements_variant_pdf_model_factory_interface(): void | ||
{ | ||
$this->shouldHaveType(VariantPdfModelFactoryInterface::class); | ||
} | ||
|
||
function it_returns_product_pdf_model(): void | ||
{ | ||
$productVariant = new ProductVariant(); | ||
$productPdfModel = $this->createWithVariantAndImagePath( | ||
$productVariant, | ||
'http://127.0.0.1:8000/media/image/b4/c2/fc6b3202ee567e0fb05f293b709c.jpg', | ||
10, | ||
'variant test' | ||
); | ||
|
||
$productPdfModel->getVariant()->shouldReturn($productVariant); | ||
$productPdfModel->getImagePath()->shouldReturn('http://127.0.0.1:8000/media/image/b4/c2/fc6b3202ee567e0fb05f293b709c.jpg'); | ||
$productPdfModel->getQuantity()->shouldReturn(10); | ||
$productPdfModel->getActualVariant()->shouldReturn('variant test'); | ||
|
||
$this->createWithVariantAndImagePath( | ||
$productVariant, | ||
'http://127.0.0.1:8000/media/image/b4/c2/fc6b3202ee567e0fb05f293b709c.jpg', | ||
10, | ||
'variant test' | ||
)->shouldBeAnInstanceOf(VariantPdfModel::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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\SyliusWishlistPlugin\Model; | ||
|
||
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModel; | ||
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModelInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\ProductVariantInterface; | ||
|
||
final class VariantPdfModelSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(VariantPdfModel::class); | ||
} | ||
|
||
function it_implements_variant_pdf_model_interface(): void | ||
{ | ||
$this->shouldHaveType(VariantPdfModelInterface::class); | ||
} | ||
|
||
function it_returns_property_of_variant_pdf_model(ProductVariantInterface $productVariant): void | ||
{ | ||
$this->setActualVariant('variant test'); | ||
$this->setVariant($productVariant); | ||
$this->setImagePath('/image/123/image.jpg'); | ||
$this->setQuantity(10); | ||
|
||
$this->getActualVariant()->shouldReturn('variant test'); | ||
$this->getVariant()->shouldReturn($productVariant); | ||
$this->getImagePath()->shouldReturn('/image/123/image.jpg'); | ||
$this->getQuantity()->shouldReturn(10); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?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\SyliusWishlistPlugin\Resolver; | ||
|
||
use BitBag\SyliusWishlistPlugin\Resolver\GenerateDataUriForImageResolverInterface; | ||
use BitBag\SyliusWishlistPlugin\Resolver\VariantImageToDataUriResolver; | ||
use Doctrine\Common\Collections\Collection; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\ProductImage; | ||
use Sylius\Component\Core\Model\ProductInterface; | ||
use Sylius\Component\Core\Model\ProductVariantInterface; | ||
|
||
final class VariantImageToDataUriResolverSpec extends ObjectBehavior | ||
{ | ||
private const TEST_BASE_URL = 'http://test:8000'; | ||
|
||
public function let(GenerateDataUriForImageResolverInterface $dataUriForImageResolver): void | ||
{ | ||
$this->beConstructedWith( | ||
$dataUriForImageResolver | ||
); | ||
} | ||
|
||
public function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(VariantImageToDataUriResolver::class); | ||
} | ||
|
||
public function it_resolve_empty_image_path( | ||
ProductVariantInterface $variant, | ||
ProductInterface $product, | ||
Collection $productImages | ||
): void { | ||
$variant->getProduct()->willReturn($product); | ||
$product->getImages()->willReturn($productImages); | ||
$productImages->first()->willReturn(false); | ||
|
||
$this->resolve($variant, self::TEST_BASE_URL)->shouldReturn(''); | ||
} | ||
|
||
public function it_resolve_image_path( | ||
ProductVariantInterface $variant, | ||
ProductInterface $product, | ||
Collection $productImages, | ||
ProductImage $productImage, | ||
GenerateDataUriForImageResolverInterface $dataUriForImageResolver | ||
): void { | ||
$variant->getProduct()->willReturn($product); | ||
$product->getImages()->willReturn($productImages); | ||
$productImages->first()->willReturn($productImage); | ||
$dataUriForImageResolver->resolve($productImage)->willReturn(self::TEST_BASE_URL); | ||
$this->resolve($variant, self::TEST_BASE_URL)->shouldReturn(self::TEST_BASE_URL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Command/Wishlist/ExportSelectedProductsFromWishlistToPdf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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 BitBag\SyliusWishlistPlugin\Command\Wishlist; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
final class ExportSelectedProductsFromWishlistToPdf implements ExportSelectedProductsFromWishlistToPdfInterface | ||
{ | ||
/** @var Collection<WishlistItem> */ | ||
private Collection $wishlistProducts; | ||
|
||
public function __construct(Collection $wishlistProducts) | ||
{ | ||
$this->wishlistProducts = $wishlistProducts; | ||
} | ||
|
||
public function getWishlistProducts(): ?Collection | ||
{ | ||
return $this->wishlistProducts; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Command/Wishlist/ExportSelectedProductsFromWishlistToPdfInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusWishlistPlugin\Command\Wishlist; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
|
||
interface ExportSelectedProductsFromWishlistToPdfInterface | ||
{ | ||
public function getWishlistProducts(): ?Collection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusWishlistPlugin\Command\Wishlist; | ||
|
||
use BitBag\SyliusWishlistPlugin\Entity\WishlistProductInterface; | ||
use Sylius\Bundle\OrderBundle\Controller\AddToCartCommandInterface; | ||
|
||
interface WishlistItemInterface | ||
{ | ||
public function getWishlistProduct(): ?WishlistProductInterface; | ||
|
||
public function setWishlistProduct(?WishlistProductInterface $wishlistProduct): void; | ||
|
||
public function isSelected(): ?bool; | ||
|
||
public function setSelected(?bool $selected): void; | ||
|
||
public function getCartItem(): ?AddToCartCommandInterface; | ||
|
||
public function setCartItem(?AddToCartCommandInterface $cartItem): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.