|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * * This file is part of MetaModels/attribute_select. |
| 5 | + * |
| 6 | + * (c) 2012-2017 The MetaModels team. |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + * |
| 11 | + * This project is provided in good faith and hope to be usable by anyone. |
| 12 | + * |
| 13 | + * @package MetaModels |
| 14 | + * @subpackage AttributeSelect |
| 15 | + * @author David Molineus <[email protected]> |
| 16 | + * @copyright 2012-2017 The MetaModels team. |
| 17 | + * @license https://github.com/MetaModels/attribute_text/blob/master/LICENSE LGPL-3.0 |
| 18 | + * @filesource |
| 19 | + */ |
| 20 | + |
| 21 | +namespace MetaModels\AttributeSelectBundle\Test\ContaoManager; |
| 22 | + |
| 23 | +use Contao\ManagerPlugin\Bundle\BundlePluginInterface; |
| 24 | +use Contao\ManagerPlugin\Bundle\Config\BundleConfig; |
| 25 | +use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; |
| 26 | +use MetaModels\AttributeSelectBundle\ContaoManager\Plugin; |
| 27 | +use MetaModels\CoreBundle\MetaModelsCoreBundle; |
| 28 | +use PHPUnit\Framework\TestCase; |
| 29 | +use Symfony\Component\Config\Loader\LoaderInterface; |
| 30 | +use Symfony\Component\Config\Loader\LoaderResolverInterface; |
| 31 | +use Symfony\Component\HttpKernel\KernelInterface; |
| 32 | + |
| 33 | +/** |
| 34 | + * Unit tests the contao manager plugin. |
| 35 | + */ |
| 36 | +class PluginTest extends TestCase |
| 37 | +{ |
| 38 | + /** |
| 39 | + * Test that plugin can be instantiated. |
| 40 | + * |
| 41 | + * @return void |
| 42 | + */ |
| 43 | + public function testInstantiation() |
| 44 | + { |
| 45 | + $plugin = new Plugin(); |
| 46 | + |
| 47 | + $this->assertInstanceOf(Plugin::class, $plugin); |
| 48 | + $this->assertInstanceOf(BundlePluginInterface::class, $plugin); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Tests that the a valid bundle config is created. |
| 53 | + * |
| 54 | + * @return void |
| 55 | + */ |
| 56 | + public function testBundleConfig() |
| 57 | + { |
| 58 | + $parser = $this->getMockBuilder(ParserInterface::class)->getMock(); |
| 59 | + $plugin = new Plugin(); |
| 60 | + $bundles = $plugin->getBundles($parser); |
| 61 | + |
| 62 | + $this->assertContainsOnlyInstancesOf(BundleConfig::class, $bundles); |
| 63 | + $this->assertCount(1, $bundles); |
| 64 | + |
| 65 | + /** @var BundleConfig $bundleConfig */ |
| 66 | + $bundleConfig = $bundles[0]; |
| 67 | + |
| 68 | + $this->assertEquals($bundleConfig->getLoadAfter(), [MetaModelsCoreBundle::class]); |
| 69 | + $this->assertEquals($bundleConfig->getReplace(), ['metamodelsattribute_select']); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Test if the routing config is loaded. |
| 74 | + * |
| 75 | + * @return void |
| 76 | + */ |
| 77 | + public function testRouting() |
| 78 | + { |
| 79 | + $loader = $this->getMockBuilder(LoaderInterface::class)->getMock(); |
| 80 | + $resolver = $this->getMockBuilder(LoaderResolverInterface::class)->getMock(); |
| 81 | + |
| 82 | + $loader |
| 83 | + ->expects($this->once()) |
| 84 | + ->method('load'); |
| 85 | + |
| 86 | + $resolver |
| 87 | + ->expects($this->once()) |
| 88 | + ->method('resolve') |
| 89 | + ->willReturn($loader); |
| 90 | + |
| 91 | + $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); |
| 92 | + |
| 93 | + $plugin = new Plugin(); |
| 94 | + $plugin->getRouteCollection($resolver, $kernel); |
| 95 | + } |
| 96 | +} |
0 commit comments