forked from Sylius/AdminOrderCreationPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Sylius#84 from bitbager/master
[General] Present admin data in the store
- Loading branch information
Showing
32 changed files
with
451 additions
and
283 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* another great project. | ||
* You can find more information about us on https://bitbag.shop and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\CmsPlugin\Resolver; | ||
|
||
use BitBag\CmsPlugin\Entity\BlockInterface; | ||
use BitBag\CmsPlugin\Repository\BlockRepositoryInterface; | ||
use BitBag\CmsPlugin\Resolver\BlockResourceResolver; | ||
use BitBag\CmsPlugin\Resolver\BlockResourceResolverInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
*/ | ||
final class BlockResourceResolverSpec extends ObjectBehavior | ||
{ | ||
function let(BlockRepositoryInterface $blockRepository, LoggerInterface $logger) | ||
{ | ||
$this->beConstructedWith($blockRepository, $logger); | ||
} | ||
|
||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(BlockResourceResolver::class); | ||
} | ||
|
||
function it_implements_block_resource_resolver_interface(): void | ||
{ | ||
$this->shouldHaveType(BlockResourceResolverInterface::class); | ||
} | ||
|
||
function it_logs_warning_if_block_was_not_found(BlockRepositoryInterface $blockRepository, LoggerInterface $logger) | ||
{ | ||
$blockRepository->findOneEnabledByCode('homepage_banner')->willReturn(null); | ||
|
||
$logger | ||
->warning(sprintf( | ||
'Block with "%s" code was not found in the database.', | ||
'homepage_banner' | ||
)) | ||
->shouldBeCalled() | ||
; | ||
|
||
$this->findOrLog('homepage_banner'); | ||
} | ||
|
||
function it_returns_block_if_found_in_database(BlockRepositoryInterface $blockRepository, BlockInterface $block) | ||
{ | ||
$blockRepository->findOneEnabledByCode('homepage_banner')->willReturn($block); | ||
|
||
$this->findOrLog('homepage_banner')->shouldReturn($block); | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* another great project. | ||
* You can find more information about us on https://bitbag.shop and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\CmsPlugin\Resolver; | ||
|
||
use BitBag\CmsPlugin\Entity\BlockInterface; | ||
use BitBag\CmsPlugin\Resolver\BlockTemplateResolver; | ||
use BitBag\CmsPlugin\Resolver\BlockTemplateResolverInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
*/ | ||
final class BlockTemplateResolverSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(BlockTemplateResolver::class); | ||
} | ||
|
||
function it_implements_block_template_resolver_interface() | ||
{ | ||
$this->shouldHaveType(BlockTemplateResolverInterface::class); | ||
} | ||
|
||
function it_returns_text_block_template(BlockInterface $block) | ||
{ | ||
$block->getType()->willReturn('text'); | ||
|
||
$this->resolveTemplate($block)->shouldReturn('@BitBagCmsPlugin/Shop/Block/Show/textBlock.html.twig'); | ||
} | ||
|
||
function it_returns_html_block_template(BlockInterface $block) | ||
{ | ||
$block->getType()->willReturn('html'); | ||
|
||
$this->resolveTemplate($block)->shouldReturn('@BitBagCmsPlugin/Shop/Block/Show/htmlBlock.html.twig'); | ||
} | ||
|
||
function it_returns_image_block_template(BlockInterface $block) | ||
{ | ||
$block->getType()->willReturn('image'); | ||
|
||
$this->resolveTemplate($block)->shouldReturn('@BitBagCmsPlugin/Shop/Block/Show/imageBlock.html.twig'); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -14,9 +14,10 @@ | |
|
||
use BitBag\CmsPlugin\Entity\BlockInterface; | ||
use BitBag\CmsPlugin\Repository\BlockRepositoryInterface; | ||
use BitBag\CmsPlugin\Resolver\BlockResourceResolverInterface; | ||
use BitBag\CmsPlugin\Resolver\BlockTemplateResolverInterface; | ||
use BitBag\CmsPlugin\Twig\Extension\RenderBlockExtension; | ||
use PhpSpec\ObjectBehavior; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
|
@@ -25,10 +26,11 @@ final class RenderBlockExtensionSpec extends ObjectBehavior | |
{ | ||
function let( | ||
BlockRepositoryInterface $blockRepository, | ||
LoggerInterface $logger | ||
BlockTemplateResolverInterface $blockTemplateResolver, | ||
BlockResourceResolverInterface $blockResourceResolver | ||
): void | ||
{ | ||
$this->beConstructedWith($blockRepository, $logger); | ||
$this->beConstructedWith($blockRepository, $blockTemplateResolver, $blockResourceResolver); | ||
} | ||
|
||
function it_is_initializable(): void | ||
|
@@ -44,61 +46,26 @@ function it_extends_twig_extension(): void | |
function it_returns_functions(): void | ||
{ | ||
$functions = $this->getFunctions(); | ||
|
||
$functions->shouldHaveCount(1); | ||
|
||
foreach ($functions as $function) { | ||
$function->shouldHaveType(\Twig_SimpleFunction::class); | ||
} | ||
} | ||
|
||
function it_adds_warning_for_not_found_block( | ||
BlockRepositoryInterface $blockRepository, | ||
LoggerInterface $logger, | ||
\Twig_Environment $twigEnvironment | ||
): void | ||
{ | ||
$blockRepository->findOneEnabledByCode('bitbag')->willReturn(null); | ||
$logger->warning('Block with "bitbag" code was not found in the database.')->shouldBeCalled(); | ||
|
||
$this->renderBlock($twigEnvironment, 'bitbag')->shouldReturn(null); | ||
} | ||
|
||
function it_renders_text_template_for_text_type( | ||
BlockRepositoryInterface $blockRepository, | ||
BlockInterface $block, | ||
\Twig_Environment $twigEnvironment | ||
): void | ||
{ | ||
$blockRepository->findOneEnabledByCode('bitbag')->willReturn($block); | ||
$block->getType()->willReturn('text'); | ||
$twigEnvironment->render('@BitBagCmsPlugin/Shop/Block/textBlock.html.twig', ['block' => $block])->shouldBeCalled(); | ||
|
||
$this->renderBlock($twigEnvironment, 'bitbag'); | ||
} | ||
|
||
function it_renders_html_template_for_html_type( | ||
BlockRepositoryInterface $blockRepository, | ||
BlockInterface $block, | ||
\Twig_Environment $twigEnvironment | ||
): void | ||
{ | ||
$blockRepository->findOneEnabledByCode('bitbag')->willReturn($block); | ||
$block->getType()->willReturn('html'); | ||
$twigEnvironment->render('@BitBagCmsPlugin/Shop/Block/htmlBlock.html.twig', ['block' => $block])->shouldBeCalled(); | ||
|
||
$this->renderBlock($twigEnvironment, 'bitbag'); | ||
} | ||
|
||
function it_renders_image_template_for_image_type( | ||
BlockRepositoryInterface $blockRepository, | ||
function it_renders_block( | ||
BlockResourceResolverInterface $blockResourceResolver, | ||
BlockTemplateResolverInterface $blockTemplateResolver, | ||
BlockInterface $block, | ||
\Twig_Environment $twigEnvironment | ||
): void | ||
{ | ||
$blockRepository->findOneEnabledByCode('bitbag')->willReturn($block); | ||
$block->getType()->willReturn('image'); | ||
$twigEnvironment->render('@BitBagCmsPlugin/Shop/Block/imageBlock.html.twig', ['block' => $block])->shouldBeCalled(); | ||
$blockResourceResolver->findOrLog('bitbag')->willReturn($block); | ||
$blockTemplateResolver->resolveTemplate($block)->willReturn('@BitBagCmsPlugin/Shop/Block/htmlBlock.html.twig'); | ||
$twigEnvironment->render('@BitBagCmsPlugin/Shop/Block/htmlBlock.html.twig', ['block' => $block])->willReturn('<div>BitBag</div>'); | ||
|
||
$this->renderBlock($twigEnvironment, 'bitbag'); | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
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.