-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
251 additions
and
0 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
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\SyliusCmsPlugin\Assigner; | ||
|
||
use BitBag\SyliusCmsPlugin\Assigner\LocalesAssigner; | ||
use BitBag\SyliusCmsPlugin\Assigner\LocalesAssignerInterface; | ||
use BitBag\SyliusCmsPlugin\Entity\LocaleAwareInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Locale\Model\LocaleInterface; | ||
use Sylius\Component\Resource\Repository\RepositoryInterface; | ||
|
||
final class LocalesAssignerSpec extends ObjectBehavior | ||
{ | ||
public function let(RepositoryInterface $localeRepository) | ||
{ | ||
$this->beConstructedWith($localeRepository); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(LocalesAssigner::class); | ||
} | ||
|
||
public function it_implements_locales_assigner_interface() | ||
{ | ||
$this->shouldImplement(LocalesAssignerInterface::class); | ||
} | ||
|
||
public function it_assigns_locales_to_locale_aware_entity( | ||
RepositoryInterface $localeRepository, | ||
LocaleAwareInterface $localesAware, | ||
LocaleInterface $locale1, | ||
LocaleInterface $locale2 | ||
) { | ||
$locale1->getCode()->willReturn('en_US'); | ||
$locale2->getCode()->willReturn('fr_FR'); | ||
|
||
$localeRepository->findAll()->willReturn([$locale1, $locale2]); | ||
|
||
$localesAware->addLocale($locale1)->shouldBeCalled(); | ||
$localesAware->addLocale($locale2)->shouldBeCalled(); | ||
|
||
$this->assign($localesAware, ['en_US', 'fr_FR']); | ||
} | ||
} |
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,54 @@ | ||
<?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\SyliusCmsPlugin\Assigner; | ||
|
||
use BitBag\SyliusCmsPlugin\Assigner\ProductsInTaxonsAssigner; | ||
use BitBag\SyliusCmsPlugin\Assigner\ProductsInTaxonsAssignerInterface; | ||
use BitBag\SyliusCmsPlugin\Entity\ProductsInTaxonsAwareInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\TaxonInterface; | ||
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface; | ||
|
||
final class ProductsInTaxonsAssignerSpec extends ObjectBehavior | ||
{ | ||
public function let(TaxonRepositoryInterface $taxonRepository) | ||
{ | ||
$this->beConstructedWith($taxonRepository); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(ProductsInTaxonsAssigner::class); | ||
} | ||
|
||
public function it_implements_products_in_taxons_assigner_interface() | ||
{ | ||
$this->shouldImplement(ProductsInTaxonsAssignerInterface::class); | ||
} | ||
|
||
public function it_assigns_taxons_to_products_in_taxons_aware_entity( | ||
TaxonRepositoryInterface $taxonRepository, | ||
ProductsInTaxonsAwareInterface $productsInTaxonsAware, | ||
TaxonInterface $taxon1, | ||
TaxonInterface $taxon2 | ||
) { | ||
$taxon1->getCode()->willReturn('taxon_code_1'); | ||
$taxon2->getCode()->willReturn('taxon_code_2'); | ||
|
||
$taxonRepository->findOneBy(['code' => 'taxon_code_1'])->willReturn($taxon1); | ||
$taxonRepository->findOneBy(['code' => 'taxon_code_2'])->willReturn($taxon2); | ||
|
||
$productsInTaxonsAware->addProductsInTaxon($taxon1)->shouldBeCalled(); | ||
$productsInTaxonsAware->addProductsInTaxon($taxon2)->shouldBeCalled(); | ||
|
||
$this->assign($productsInTaxonsAware, ['taxon_code_1', 'taxon_code_2']); | ||
} | ||
} |
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,48 @@ | ||
<?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\SyliusCmsPlugin\Resolver; | ||
|
||
use BitBag\SyliusCmsPlugin\Assigner\LocalesAssignerInterface; | ||
use BitBag\SyliusCmsPlugin\Entity\LocaleAwareInterface; | ||
use BitBag\SyliusCmsPlugin\Resolver\ImporterLocalesResolver; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class ImporterLocalesResolverSpec extends ObjectBehavior | ||
{ | ||
public function let(LocalesAssignerInterface $localesAssigner) | ||
{ | ||
$this->beConstructedWith($localesAssigner); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(ImporterLocalesResolver::class); | ||
} | ||
|
||
public function it_resolves_locales_for_locale_aware_entity( | ||
LocalesAssignerInterface $localesAssigner, | ||
LocaleAwareInterface $localesAware | ||
) { | ||
$localesRow = 'en_US, fr_FR'; | ||
$localesAssigner->assign($localesAware, ['en_US', 'fr_FR'])->shouldBeCalled(); | ||
|
||
$this->resolve($localesAware, $localesRow); | ||
} | ||
|
||
public function it_does_not_assign_locales_when_locales_row_is_empty( | ||
LocalesAssignerInterface $localesAssigner, | ||
LocaleAwareInterface $localesAware | ||
) { | ||
$localesAssigner->assign($localesAware, [])->shouldNotBeCalled(); | ||
|
||
$this->resolve($localesAware, ''); | ||
} | ||
} |
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,48 @@ | ||
<?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\SyliusCmsPlugin\Resolver; | ||
|
||
use BitBag\SyliusCmsPlugin\Assigner\ProductsInTaxonsAssignerInterface; | ||
use BitBag\SyliusCmsPlugin\Entity\ProductsInTaxonsAwareInterface; | ||
use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsInTaxonsResolver; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class ImporterProductsInTaxonsResolverSpec extends ObjectBehavior | ||
{ | ||
public function let(ProductsInTaxonsAssignerInterface $productsInTaxonsAssigner) | ||
{ | ||
$this->beConstructedWith($productsInTaxonsAssigner); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(ImporterProductsInTaxonsResolver::class); | ||
} | ||
|
||
public function it_resolves_taxons_for_products_in_taxons_aware_entity( | ||
ProductsInTaxonsAssignerInterface $productsInTaxonsAssigner, | ||
ProductsInTaxonsAwareInterface $productsInTaxonsAware | ||
) { | ||
$taxonsRow = 'taxon_code_1, taxon_code_2'; | ||
$productsInTaxonsAssigner->assign($productsInTaxonsAware, ['taxon_code_1', 'taxon_code_2'])->shouldBeCalled(); | ||
|
||
$this->resolve($productsInTaxonsAware, $taxonsRow); | ||
} | ||
|
||
public function it_does_not_assign_taxons_when_taxons_row_is_null( | ||
ProductsInTaxonsAssignerInterface $productsInTaxonsAssigner, | ||
ProductsInTaxonsAwareInterface $productsInTaxonsAware | ||
) { | ||
$productsInTaxonsAssigner->assign($productsInTaxonsAware, [])->shouldNotBeCalled(); | ||
|
||
$this->resolve($productsInTaxonsAware, null); | ||
} | ||
} |
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,48 @@ | ||
<?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\SyliusCmsPlugin\Resolver; | ||
|
||
use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssignerInterface; | ||
use BitBag\SyliusCmsPlugin\Entity\TaxonAwareInterface; | ||
use BitBag\SyliusCmsPlugin\Resolver\ImporterTaxonsResolver; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class ImporterTaxonsResolverSpec extends ObjectBehavior | ||
{ | ||
public function let(TaxonsAssignerInterface $taxonsAssigner) | ||
{ | ||
$this->beConstructedWith($taxonsAssigner); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(ImporterTaxonsResolver::class); | ||
} | ||
|
||
public function it_resolves_taxons_for_taxon_aware_entity( | ||
TaxonsAssignerInterface $taxonsAssigner, | ||
TaxonAwareInterface $taxonsAware | ||
) { | ||
$taxonsRow = 'taxon_code_1, taxon_code_2'; | ||
$taxonsAssigner->assign($taxonsAware, ['taxon_code_1', 'taxon_code_2'])->shouldBeCalled(); | ||
|
||
$this->resolve($taxonsAware, $taxonsRow); | ||
} | ||
|
||
public function it_does_not_assign_taxons_when_taxons_row_is_null( | ||
TaxonsAssignerInterface $taxonsAssigner, | ||
TaxonAwareInterface $taxonsAware | ||
) { | ||
$taxonsAssigner->assign($taxonsAware, [])->shouldNotBeCalled(); | ||
|
||
$this->resolve($taxonsAware, null); | ||
} | ||
} |