-
Notifications
You must be signed in to change notification settings - Fork 47
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 #20 from stefandoorn/providers-enable-disable
Enable/disable default providers (fixes #19)
- Loading branch information
Showing
8 changed files
with
170 additions
and
26 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
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="sylius.sitemap_provider.product" class="SitemapPlugin\Provider\ProductUrlProvider"> | ||
<argument type="service" id="sylius.repository.product" /> | ||
<argument type="service" id="router" /> | ||
<argument type="service" id="sylius.sitemap_url_factory" /> | ||
<argument type="service" id="sylius.context.locale" /> | ||
<argument type="service" id="sylius.context.channel" /> | ||
<tag name="sylius.sitemap_provider" /> | ||
</service> | ||
</services> | ||
</container> |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="sylius.sitemap_provider.static" class="SitemapPlugin\Provider\StaticUrlProvider"> | ||
<argument type="service" id="router" /> | ||
<argument type="service" id="sylius.sitemap_url_factory" /> | ||
<argument type="service" id="sylius.context.locale" /> | ||
<argument>%sylius.sitemap_static%</argument> | ||
<tag name="sylius.sitemap_provider" /> | ||
</service> | ||
</services> | ||
</container> |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="sylius.sitemap_provider.taxon" class="SitemapPlugin\Provider\TaxonUrlProvider"> | ||
<argument type="service" id="sylius.repository.taxon" /> | ||
<argument type="service" id="router" /> | ||
<argument type="service" id="sylius.sitemap_url_factory" /> | ||
<argument type="service" id="sylius.context.locale" /> | ||
<argument>%sylius.sitemap_exclude_taxon_root%</argument> | ||
<tag name="sylius.sitemap_provider" /> | ||
</service> | ||
</services> | ||
</container> |
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
110 changes: 110 additions & 0 deletions
110
tests/DependencyInjection/Compiler/SitemapParameterTest.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,110 @@ | ||
<?php | ||
|
||
namespace Tests\SitemapPlugin\DependencyInjection\Compiler; | ||
|
||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; | ||
use SitemapPlugin\DependencyInjection\SitemapExtension; | ||
|
||
/** | ||
* @author Stefan Doorn <[email protected]> | ||
*/ | ||
class SitemapParameterTest extends AbstractExtensionTestCase | ||
{ | ||
/** | ||
* @test | ||
* @dataProvider providers | ||
*/ | ||
public function it_has_providers_enabled_by_default_with_parameter( | ||
array $config, | ||
bool $products, | ||
bool $taxons, | ||
bool $static | ||
) { | ||
$this->load($config); | ||
|
||
$this->assertContainerBuilderHasParameter(sprintf('sylius.provider.%s', 'products'), $products); | ||
$this->assertContainerBuilderHasParameter(sprintf('sylius.provider.%s', 'taxons'), $taxons); | ||
$this->assertContainerBuilderHasParameter(sprintf('sylius.provider.%s', 'static'), $static); | ||
|
||
if ($products) { | ||
$this->assertContainerBuilderHasService('sylius.sitemap_provider.product', \SitemapPlugin\Provider\ProductUrlProvider::class); | ||
$this->assertContainerBuilderHasServiceDefinitionWithTag('sylius.sitemap_provider.product', 'sylius.sitemap_provider'); | ||
} | ||
else { | ||
$this->assertContainerBuilderNotHasService('sylius.sitemap_provider.product'); | ||
} | ||
|
||
if ($taxons) { | ||
$this->assertContainerBuilderHasService('sylius.sitemap_provider.taxon', \SitemapPlugin\Provider\TaxonUrlProvider::class); | ||
$this->assertContainerBuilderHasServiceDefinitionWithTag('sylius.sitemap_provider.taxon', 'sylius.sitemap_provider'); | ||
|
||
} | ||
else { | ||
$this->assertContainerBuilderNotHasService('sylius.sitemap_provider.taxon'); | ||
} | ||
|
||
if ($static) { | ||
$this->assertContainerBuilderHasService('sylius.sitemap_provider.static', \SitemapPlugin\Provider\StaticUrlProvider::class); | ||
$this->assertContainerBuilderHasServiceDefinitionWithTag('sylius.sitemap_provider.static', 'sylius.sitemap_provider'); | ||
|
||
} | ||
else { | ||
$this->assertContainerBuilderNotHasService('sylius.sitemap_provider.static'); | ||
} | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function providers(): array | ||
{ | ||
return [ | ||
[ | ||
['providers' => [ | ||
'products' => true, | ||
'taxons' => true, | ||
'static' => true, | ||
]], | ||
true, | ||
true, | ||
true | ||
], | ||
[ | ||
['providers' => []], | ||
true, | ||
true, | ||
true, | ||
], | ||
[ | ||
['providers' => [ | ||
'products' => false, | ||
'taxons' => false, | ||
'static' => false, | ||
]], | ||
false, | ||
false, | ||
false | ||
], | ||
[ | ||
['providers' => [ | ||
'products' => true, | ||
'taxons' => false, | ||
'static' => true, | ||
]], | ||
true, | ||
false, | ||
true, | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function getContainerExtensions() | ||
{ | ||
return array( | ||
new SitemapExtension() | ||
); | ||
} | ||
} |