|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace ExpertCoder\Swiftmailer\SendGridBundle\Tests; |
| 4 | + |
| 5 | +use Nyholm\BundleTest\BaseBundleTestCase; |
| 6 | +use Nyholm\BundleTest\CompilerPass\PublicServicePass; |
| 7 | +use ExpertCoder\Swiftmailer\SendGridBundle\ExpertCoderSwiftmailerSendGridBundle; |
| 8 | +use ExpertCoder\Swiftmailer\SendGridBundle\Services\SendGridTransport; |
| 9 | + |
| 10 | +class BundleInitializationTest extends BaseBundleTestCase |
| 11 | +{ |
| 12 | + protected function getBundleClass() |
| 13 | + { |
| 14 | + return ExpertCoderSwiftmailerSendGridBundle::class; |
| 15 | + } |
| 16 | + |
| 17 | + protected function setUp() |
| 18 | + { |
| 19 | + parent::setUp(); |
| 20 | + |
| 21 | + // Make services public that have an idea that matches a regex |
| 22 | + $this->addCompilerPass(new PublicServicePass('|expertcoder_swift_mailer.*|')); |
| 23 | + } |
| 24 | + |
| 25 | + public function testInitBundle() |
| 26 | + { |
| 27 | + // Boot the kernel. |
| 28 | + $this->bootKernel(); |
| 29 | + |
| 30 | + // Get the container |
| 31 | + $container = $this->getContainer(); |
| 32 | + |
| 33 | + // Test if services exists |
| 34 | + $this->assertTrue($container->has('expertcoder_swift_mailer.send_grid.transport')); |
| 35 | + $service = $container->get('expertcoder_swift_mailer.send_grid.transport'); |
| 36 | + $this->assertInstanceOf(SendGridTransport::class, $service); |
| 37 | + |
| 38 | + // Test if parameters exists |
| 39 | + $this->assertTrue($container->hasParameter('expertcoder_swiftmailer_sendgrid.api_key')); |
| 40 | + $this->assertTrue($container->hasParameter('expertcoder_swiftmailer_sendgrid.categories')); |
| 41 | + } |
| 42 | + |
| 43 | + public function testBundleWithDifferentConfiguration() |
| 44 | + { |
| 45 | + // Create a new Kernel |
| 46 | + $kernel = $this->createKernel(); |
| 47 | + |
| 48 | + // Add some configuration |
| 49 | + $kernel->addConfigFile(__DIR__.'/config.yml'); |
| 50 | + |
| 51 | + // Add some other bundles we depend on |
| 52 | + $kernel->addBundle(OtherBundle::class); |
| 53 | + |
| 54 | + // Boot the kernel as normal ... |
| 55 | + $this->bootKernel(); |
| 56 | + |
| 57 | + // ... |
| 58 | + } |
| 59 | +} |
0 commit comments