1 | <?php |
||
2 | /* |
||
3 | * @copyright 2018 Mautic Contributors. All rights reserved |
||
4 | * @author Mautic |
||
5 | * |
||
6 | * @link http://mautic.org |
||
7 | * |
||
8 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
9 | */ |
||
10 | |||
11 | namespace Mautic\SmsBundle\Tests\DependencyInjection\Compiler; |
||
12 | |||
13 | use Mautic\PluginBundle\Helper\IntegrationHelper; |
||
14 | use Mautic\SmsBundle\DependencyInjection\Compiler\SmsTransportPass; |
||
15 | use Mautic\SmsBundle\Sms\TransportChain; |
||
16 | use PHPUnit\Framework\TestCase; |
||
17 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
18 | |||
19 | class SmsTransportPassTest extends TestCase |
||
20 | { |
||
21 | public function testProcess() |
||
22 | { |
||
23 | $container = new ContainerBuilder(); |
||
24 | $container->addCompilerPass(new SmsTransportPass()); |
||
25 | $container |
||
26 | ->register('foo') |
||
27 | ->setPublic(true) |
||
28 | ->setAbstract(true) |
||
29 | ->addTag('mautic.sms_transport', ['alias'=>'fakeAliasDefault', 'integrationAlias' => 'fakeIntegrationDefault']); |
||
30 | |||
31 | $container |
||
32 | ->register('chocolate') |
||
33 | ->setPublic(true) |
||
34 | ->setAbstract(true); |
||
35 | |||
36 | $container |
||
37 | ->register('bar') |
||
38 | ->setPublic(true) |
||
39 | ->setAbstract(true) |
||
40 | ->addTag('mautic.sms_transport'); |
||
41 | |||
42 | $transport = $this->getMockBuilder(TransportChain::class) |
||
0 ignored issues
–
show
|
|||
43 | ->disableOriginalConstructor() |
||
44 | ->setMethods(['addTransport']) |
||
45 | ->getMock(); |
||
46 | |||
47 | $container |
||
48 | ->register('mautic.sms.transport_chain') |
||
49 | ->setClass(get_class($transport)) |
||
50 | ->setArguments(['foo', $this->createMock(IntegrationHelper::class)]) |
||
51 | ->setShared(false) |
||
52 | ->setSynthetic(true) |
||
53 | ->setAbstract(true); |
||
54 | |||
55 | $pass = new SmsTransportPass(); |
||
56 | $pass->process($container); |
||
57 | |||
58 | $this->assertEquals(2, count($container->findTaggedServiceIds('mautic.sms_transport'))); |
||
59 | |||
60 | $methodCalls = $container->getDefinition('mautic.sms.transport_chain')->getMethodCalls(); |
||
61 | $this->assertCount(count($methodCalls), $container->findTaggedServiceIds('mautic.sms_transport')); |
||
62 | |||
63 | // Translation string |
||
64 | $this->assertEquals('fakeAliasDefault', $methodCalls[0][1][2]); |
||
65 | // Integration name/alias |
||
66 | $this->assertEquals('fakeIntegrationDefault', $methodCalls[0][1][3]); |
||
67 | |||
68 | // Translation string is set as service ID by default |
||
69 | $this->assertEquals('bar', $methodCalls[1][1][2]); |
||
70 | // Integration name/alias is set to service ID by default |
||
71 | $this->assertEquals('bar', $methodCalls[1][1][3]); |
||
72 | } |
||
73 | } |
||
74 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.