|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Flagbit\Bundle\CurrencyBundle\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Flagbit\Bundle\CurrencyBundle\DependencyInjection\FlagbitCurrencyExtension; |
|
6
|
|
|
use Flagbit\Bundle\CurrencyBundle\Service\Currency; |
|
7
|
|
|
use Flagbit\Bundle\CurrencyBundle\Twig\FlagbitCurrencyExtension as TwigExtension; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
11
|
|
|
use Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface; |
|
12
|
|
|
|
|
13
|
|
|
class FlagbitCurrencyExtensionTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function testCurrencyServiceIntegration() |
|
16
|
|
|
{ |
|
17
|
|
|
$container = new ContainerBuilder(); |
|
18
|
|
|
$config = []; |
|
19
|
|
|
|
|
20
|
|
|
$extension = new FlagbitCurrencyExtension(); |
|
21
|
|
|
$extension->load($config, $container); |
|
22
|
|
|
|
|
23
|
|
|
$this->setDefinitionPublic(TwigExtension::class, $container); |
|
24
|
|
|
$this->setDefinitionPublic(Currency::class, $container); |
|
25
|
|
|
|
|
26
|
|
|
$container->compile(); |
|
27
|
|
|
|
|
28
|
|
|
$currency = $container->get(Currency::class); |
|
29
|
|
|
$currencyExtension = $container->get(TwigExtension::class); |
|
30
|
|
|
|
|
31
|
|
|
$this->assertInstanceOf(Currency::class, $currency); |
|
32
|
|
|
$this->assertInstanceOf(TwigExtension::class, $currencyExtension); |
|
33
|
|
|
|
|
34
|
|
|
$currencyBundle = $container->get('flagbit_currency.intl_bundle'); |
|
35
|
|
|
$currency = $container->get('flagbit_currency'); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertInstanceOf(CurrencyBundleInterface::class, $currencyBundle); |
|
38
|
|
|
$this->assertInstanceOf(Currency::class, $currency); |
|
39
|
|
|
$this->assertInstanceOf(TwigExtension::class, $currencyExtension); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $serviceName |
|
44
|
|
|
* @param ContainerBuilder $container |
|
45
|
|
|
*/ |
|
46
|
|
|
private function setDefinitionPublic(string $serviceName, ContainerBuilder $container) |
|
47
|
|
|
{ |
|
48
|
|
|
$container->findDefinition($serviceName) |
|
49
|
|
|
->setPublic(true); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|