Skip to content

Commit

Permalink
added amp support, updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Aug 23, 2019
1 parent 0608986 commit 34fc665
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.3.0] - 2019-08-23

- added amp support for download inserttag

## [0.2.0] - 2019-08-22

- added small and endsmall insert tags
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -6,6 +6,8 @@

This bundle provides some additional inserttags for contao CMS.

The download inserttag template is already prepared for [AMP Bundle](https://github.com/heimrichhannot/contao-amp-bundle).

## Inserttags

Inserttag | Example | Description
Expand Down Expand Up @@ -38,4 +40,3 @@ See [upgrade notices](docs/upgrade.md) for more information.




17 changes: 16 additions & 1 deletion src/ContaoManager/Plugin.php
Expand Up @@ -13,10 +13,13 @@
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
use Contao\ManagerPlugin\Config\ConfigPluginInterface;
use Contao\ManagerPlugin\Config\ContainerBuilder;
use Contao\ManagerPlugin\Config\ExtensionPluginInterface;
use HeimrichHannot\ContaoInserttagCollectionBundle\HeimrichHannotContaoInserttagCollectionBundle;
use HeimrichHannot\UtilsBundle\Container\ContainerUtil;
use Symfony\Component\Config\Loader\LoaderInterface;

class Plugin implements BundlePluginInterface, ConfigPluginInterface
class Plugin implements BundlePluginInterface, ConfigPluginInterface, ExtensionPluginInterface
{
/**
* {@inheritdoc}
Expand All @@ -36,4 +39,16 @@ public function registerContainerConfiguration(LoaderInterface $loader, array $m
{
$loader->load('@HeimrichHannotContaoInserttagCollectionBundle/Resources/config/services.yml');
}

/**
* Allows a plugin to override extension configuration.
*
* @param string $extensionName
*
* @return array<string,mixed>
*/
public function getExtensionConfig($extensionName, array $extensionConfigs, ContainerBuilder $container)
{
return ContainerUtil::mergeConfigFile('huh_amp', $extensionName, $extensionConfigs, __DIR__.'/../Resources/config/config_amp.yml');
}
}
3 changes: 3 additions & 0 deletions src/Resources/config/config_amp.yml
@@ -0,0 +1,3 @@
huh_amp:
templates:
ce_download_inserttag: ~
@@ -0,0 +1,5 @@
<span class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
<a href="<?php echo $this->href; ?>" title="<?php echo $this->title; ?>">
<?php echo $this->link; ?> <span class="size">(<?php echo $this->filesize; ?>)</span>
</a>
</span>
23 changes: 21 additions & 2 deletions tests/ContaoManager/PluginTest.php
Expand Up @@ -11,11 +11,13 @@
use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\Parser\DelegatingParser;
use Contao\ManagerPlugin\Config\ContainerBuilder;
use Contao\TestCase\ContaoTestCase;
use HeimrichHannot\ContaoInserttagCollectionBundle\ContaoManager\Plugin;
use HeimrichHannot\ContaoInserttagCollectionBundle\HeimrichHannotContaoInserttagCollectionBundle;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Loader\LoaderInterface;

class PluginTest extends TestCase
class PluginTest extends ContaoTestCase
{
public function testInstantiation()
{
Expand All @@ -34,4 +36,21 @@ public function testGetBundles()
$this->assertSame(HeimrichHannotContaoInserttagCollectionBundle::class, $bundles[0]->getName());
$this->assertSame([ContaoCoreBundle::class], $bundles[0]->getLoadAfter());
}

public function testRegisterContainerConfiguration()
{
$plugin = new Plugin();
$loader = $this->createMock(LoaderInterface::class);
$loader->expects($this->once())->method('load');
$plugin->registerContainerConfiguration($loader, []);
}

public function testGetExtensionConfig()
{
$plugin = new Plugin();
$container = $this->createMock(ContainerBuilder::class);
$this->assertEmpty($plugin->getExtensionConfig('test', [], $container));

$this->assertArrayHasKey('huh_amp', $plugin->getExtensionConfig('huh_amp', [], $container));
}
}

0 comments on commit 34fc665

Please sign in to comment.