1 | <?php |
||
12 | class ProviderPassTest extends AbstractCompilerPassTestCase |
||
13 | { |
||
14 | use MockeryTrait; |
||
15 | |||
16 | protected function registerCompilerPass(ContainerBuilder $container) |
||
17 | { |
||
18 | $container->addCompilerPass(new ProviderPass()); |
||
19 | } |
||
20 | |||
21 | public function testIfCompilerPassAddsMethodCalls() |
||
22 | { |
||
23 | $this->compileContainer(); |
||
24 | } |
||
25 | |||
26 | public function testIfCompilerPassUsesImageConstraintsFromConfig() |
||
27 | { |
||
28 | $this->compileContainer([ |
||
29 | 'image_constraints' => ['foo' => 'bar'] |
||
30 | ]); |
||
31 | } |
||
32 | |||
33 | private function compileContainer($config = [[]]) |
||
34 | { |
||
35 | $this->setParameter('mediamonks.sonata_media.config', $config); |
||
36 | |||
37 | if (empty($config['image_constraints'])) { |
||
38 | $config['image_constraints'] = []; |
||
39 | } |
||
40 | |||
41 | $provider = m::mock(Definition::class); |
||
42 | $provider->shouldReceive('isLazy')->andReturn(false); |
||
43 | $provider->shouldReceive('isSynthetic')->andReturn(false); |
||
44 | $provider->shouldReceive('getClass')->andReturn(self::class); |
||
45 | $provider->shouldReceive('getInstanceofConditionals')->andReturn([]); |
||
46 | $provider->shouldReceive('isAutoconfigured')->andReturn(true); |
||
47 | $provider->shouldReceive('hasTag')->withArgs(['sonata_media.provider'])->andReturn(true); |
||
48 | $provider->shouldReceive('getTag')->withArgs(['sonata_media.provider'])->andReturn(true); |
||
49 | $provider->shouldReceive('addMethodCall')->once()->withArgs(['setFilesystem', \Mockery::any()]); |
||
50 | $provider->shouldReceive('addMethodCall')->once()->withArgs(['setImageConstraintOptions', [$config['image_constraints']]]); |
||
51 | $provider->shouldReceive('addMethodCall')->once()->withArgs(['setTranslator', \Mockery::any()]); |
||
52 | $provider->shouldReceive('addMethodCall')->once()->withArgs(['setHttpClient', \Mockery::any()]); |
||
53 | $provider->shouldReceive('addMethodCall')->once()->withArgs(['setFileLocator', \Mockery::any()]); |
||
54 | $this->setDefinition('provider', $provider); |
||
55 | |||
56 | $this->compile(); |
||
57 | |||
58 | $this->assertTrue(true); |
||
59 | } |
||
60 | } |
||
61 |