|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\SwiftmailerBundle\Tests\DependencyInjection; |
|
13 |
|
14 use Symfony\Bundle\SwiftmailerBundle\Tests\TestCase; |
|
15 use Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerExtension; |
|
16 use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
17 |
|
18 class SwiftmailerExtensionTest extends TestCase |
|
19 { |
|
20 public function testConfigLoad() |
|
21 { |
|
22 $container = new ContainerBuilder(); |
|
23 $container->setParameter('kernel.debug', false); |
|
24 $loader = new SwiftmailerExtension(); |
|
25 |
|
26 $loader->load(array(array()), $container); |
|
27 $this->assertEquals('Swift_Mailer', $container->getParameter('swiftmailer.class'), '->load() loads the swiftmailer.xml file if not already loaded'); |
|
28 |
|
29 $loader->load(array(array('transport' => 'sendmail')), $container); |
|
30 $this->assertEquals('swiftmailer.transport.sendmail', (string) $container->getAlias('swiftmailer.transport')); |
|
31 |
|
32 $loader->load(array(array()), $container); |
|
33 $this->assertEquals('swiftmailer.transport.smtp', (string) $container->getAlias('swiftmailer.transport')); |
|
34 } |
|
35 |
|
36 public function testNullTransport() |
|
37 { |
|
38 $container = new ContainerBuilder(); |
|
39 $container->setParameter('kernel.debug', false); |
|
40 $loader = new SwiftmailerExtension(); |
|
41 |
|
42 $loader->load(array(array('transport' => null)), $container); |
|
43 $this->assertEquals('swiftmailer.transport.null', (string) $container->getAlias('swiftmailer.transport')); |
|
44 } |
|
45 |
|
46 public function testSpool() |
|
47 { |
|
48 $container = new ContainerBuilder(); |
|
49 $container->setParameter('kernel.debug', false); |
|
50 $loader = new SwiftmailerExtension(); |
|
51 |
|
52 $loader->load(array(array('spool' => array())), $container); |
|
53 $this->assertEquals('swiftmailer.transport.spool', (string) $container->getAlias('swiftmailer.transport')); |
|
54 $this->assertEquals('swiftmailer.transport.smtp', (string) $container->getAlias('swiftmailer.transport.real')); |
|
55 } |
|
56 |
|
57 } |