-
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.
- Loading branch information
marcofaul
committed
May 16, 2020
1 parent
b6c66f3
commit 6828157
Showing
14 changed files
with
290 additions
and
100 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,20 @@ | ||
codecov: | ||
require_ci_to_pass: true | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "70...100" | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: yes | ||
loop: yes | ||
method: no | ||
macro: no | ||
|
||
comment: | ||
layout: "reach,diff,flags,tree" | ||
behavior: default | ||
require_changes: false |
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/DependencyInjection/Compiler/OverrideConfigurationCompilerPass.php
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/DependencyInjection/Compiler/OverrideConfigurationPass.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,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MarcoFaul\SwDevToolSixBundle\DependencyInjection\Compiler; | ||
|
||
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntitySearcher; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class OverrideConfigurationPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$container->setParameter('shopware.store.frw', $container->getParameter('sw_dev_tool_six.shopware.skip_first_run_wizard_client')); | ||
$container->setParameter('shopware.auto_update.disableAutoUpdate', !$container->getParameter('sw_dev_tool_six.shopware.enable_auto_update')); | ||
$container->setParameter('shopware.api_browser.auth_required', $container->getParameter('sw_dev_tool_six.shopware.enable_api_auth_require')); | ||
$container->setParameter('storefront.csrf.enabled', $container->getParameter('sw_dev_tool_six.shopware.enable_storefront_csrf')); | ||
|
||
if ($container->getParameter('sw_dev_tool_six.enable_dal_caching') === false) { | ||
$container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Cache\CachedEntitySearcher') | ||
->setClass(EntitySearcher::class) | ||
->setArgument(0, $container->getDefinition('Doctrine\DBAL\Connection')) | ||
->setArgument(1, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Parser\SqlQueryParser')) | ||
->setArgument(2, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntityDefinitionQueryHelper')) | ||
->setArgument(3, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Term\SearchTermInterpreter')) | ||
->setArgument(4, $container->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Term\EntityScoreQueryBuilder')); | ||
} | ||
} | ||
} |
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
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
34 changes: 34 additions & 0 deletions
34
tests/PHPUnit/Api/EventListener/Authentication/ApiAuthenticationListenerExtensionTest.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,34 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace MarcoFaul\SwDevToolSixBundle\Tests\PHPUnit\Api\EventListener\Authentication; | ||
|
||
|
||
use League\OAuth2\Server\AuthorizationServer; | ||
use League\OAuth2\Server\Grant\ClientCredentialsGrant; | ||
use League\OAuth2\Server\Grant\PasswordGrant; | ||
use League\OAuth2\Server\Grant\RefreshTokenGrant; | ||
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface; | ||
use League\OAuth2\Server\Repositories\UserRepositoryInterface; | ||
use League\OAuth2\Server\ResourceServer; | ||
use PHPUnit\Framework\TestCase; | ||
use Shopware\Core\Framework\Routing\ApiContextRouteScopeDependant; | ||
use Shopware\Core\Framework\Routing\KernelListenerPriorities; | ||
use Shopware\Core\Framework\Routing\RouteScopeCheckTrait; | ||
use Shopware\Core\Framework\Routing\RouteScopeRegistry; | ||
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpKernel\Event\ControllerEvent; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
|
||
class ApiAuthenticationListenerExtensionTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function blub() | ||
{ | ||
$this->assertEquals(42, 42); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
tests/PHPUnit/DependencyInjection/Compiler/OverrideConfigurationPassTest.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,72 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace MarcoFaul\SwDevToolSixBundle\Tests\PHPUnit\DependencyInjection\Compiler; | ||
|
||
|
||
use Doctrine\DBAL\Connection; | ||
use MarcoFaul\SwDevToolSixBundle\DependencyInjection\Compiler\OverrideConfigurationPass; | ||
use PHPUnit\Framework\TestCase; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntityDefinitionQueryHelper; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntitySearcher; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Parser\SqlQueryParser; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Term\EntityScoreQueryBuilder; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Term\SearchTermInterpreter; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
class OverrideConfigurationPassTest extends TestCase | ||
{ | ||
/** @var ContainerBuilder */ | ||
private $containerBuilder; | ||
|
||
/** @var OverrideConfigurationPass */ | ||
private $pass; | ||
|
||
/** | ||
* initialize all services once | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->pass = new OverrideConfigurationPass(); | ||
$this->containerBuilder = new ContainerBuilder(); | ||
$this->containerBuilder->setParameter('sw_dev_tool_six.shopware.skip_first_run_wizard_client', true); | ||
$this->containerBuilder->setParameter('sw_dev_tool_six.shopware.enable_auto_update', true); | ||
$this->containerBuilder->setParameter('sw_dev_tool_six.shopware.enable_api_auth_require', true); | ||
$this->containerBuilder->setParameter('sw_dev_tool_six.shopware.enable_storefront_csrf', true); | ||
$this->containerBuilder->setParameter('sw_dev_tool_six.enable_dal_caching', true); | ||
} | ||
|
||
/** | ||
* @test | ||
* @group configuration | ||
*/ | ||
public function process() | ||
{ | ||
$this->pass->process($this->containerBuilder); | ||
|
||
$this->assertTrue($this->containerBuilder->getParameter('sw_dev_tool_six.shopware.skip_first_run_wizard_client')); | ||
$this->assertTrue($this->containerBuilder->getParameter('sw_dev_tool_six.shopware.enable_auto_update')); | ||
$this->assertTrue($this->containerBuilder->getParameter('sw_dev_tool_six.shopware.enable_api_auth_require')); | ||
$this->assertTrue($this->containerBuilder->getParameter('sw_dev_tool_six.shopware.enable_storefront_csrf')); | ||
} | ||
|
||
/** | ||
* @test | ||
* @group configuration | ||
*/ | ||
public function overrideCachedEntity() | ||
{ | ||
$this->containerBuilder->setParameter('sw_dev_tool_six.enable_dal_caching', false); | ||
$this->containerBuilder->setDefinition('Shopware\Core\Framework\DataAbstractionLayer\Cache\CachedEntitySearcher', new Definition(CachedEntitySearcher::class, [])); | ||
$this->containerBuilder->setDefinition('Doctrine\DBAL\Connection', new Definition(Connection::class, [])); | ||
$this->containerBuilder->setDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Parser\SqlQueryParser', new Definition(SqlQueryParser::class, [])); | ||
$this->containerBuilder->setDefinition('Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntityDefinitionQueryHelper', new Definition(EntityDefinitionQueryHelper::class, [])); | ||
$this->containerBuilder->setDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Term\SearchTermInterpreter', new Definition(SearchTermInterpreter::class, [])); | ||
$this->containerBuilder->setDefinition('Shopware\Core\Framework\DataAbstractionLayer\Search\Term\EntityScoreQueryBuilder', new Definition(EntityScoreQueryBuilder::class, [])); | ||
|
||
$this->pass->process($this->containerBuilder); | ||
|
||
$this->assertEquals(EntitySearcher::class, $this->containerBuilder->getDefinition('Shopware\Core\Framework\DataAbstractionLayer\Cache\CachedEntitySearcher')->getClass()); | ||
} | ||
} |
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,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace MarcoFaul\SwDevToolSixBundle\Tests\PHPUnit\DependencyInjection; | ||
|
||
|
||
use MarcoFaul\SwDevToolSixBundle\DependencyInjection\Configuration; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ConfigurationTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$configuration = new Configuration(); | ||
$configTreeBuilder = $configuration->getConfigTreeBuilder(); | ||
|
||
$this->assertEquals('sw_dev_tool_six', $configTreeBuilder->buildTree()->getName()); | ||
|
||
$this->assertEquals(3, \count($configTreeBuilder->buildTree()->getChildren())); | ||
$this->assertEquals(4, \count($configTreeBuilder->buildTree()->getChildren()['shopware']->getChildren())); | ||
|
||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/PHPUnit/DependencyInjection/SwDevToolSixExtensionTest.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,44 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace MarcoFaul\SwDevToolSixBundle\Tests\PHPUnit\DependencyInjection; | ||
|
||
|
||
use MarcoFaul\SwDevToolSixBundle\DependencyInjection\SwDevToolSixExtension; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class SwDevToolSixExtensionTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function load() | ||
{ | ||
$containerBuilder = new ContainerBuilder(); | ||
$configs = [ | ||
'access_token_ttl' => 'P1W', | ||
'enable_dal_caching' => false, | ||
'shopware' => [ | ||
'skip_first_run_wizard_client' => true, | ||
'enable_auto_update' => false, | ||
'enable_api_auth_require' => false, | ||
'enable_storefront_csrf' => false | ||
] | ||
]; | ||
$swDevToolSixExtension = new SwDevToolSixExtension(); | ||
$swDevToolSixExtension->load([$configs], $containerBuilder); | ||
|
||
|
||
$expected = [ | ||
'sw_dev_tool_six.access_token_ttl' => 'P1W', | ||
'sw_dev_tool_six.enable_dal_caching' => false, | ||
'sw_dev_tool_six.shopware.skip_first_run_wizard_client' => true, | ||
'sw_dev_tool_six.shopware.enable_auto_update' => false, | ||
'sw_dev_tool_six.shopware.enable_api_auth_require' => false, | ||
'sw_dev_tool_six.shopware.enable_storefront_csrf' => false, | ||
]; | ||
|
||
$this->assertEquals($expected, $containerBuilder->getParameterBag()->all()); | ||
} | ||
} |
Oops, something went wrong.