Source of file SchemaServiceTest.php
Size: 2,569 Bytes - Last Modified: 2021-12-24T06:51:36+00:00
/var/www/docs.ssmods.com/process/src/tests/DependencyInjection/CompilerPass/SchemaServiceTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | <?php namespace Heystack\Core\DependencyInjection\CompilerPass; use Heystack\Core\Services; use Symfony\Component\DependencyInjection\Reference; class SchemaServiceTest extends \PHPUnit_Framework_TestCase { /** * @covers \Heystack\Core\DependencyInjection\CompilerPass\SchemaService::process */ public function testProcessHasDefinition() { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $testDefinition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); $testDefinition ->expects($this->at(0)) ->method('addMethodCall') ->with('setReference', [true]); $testDefinition ->expects($this->at(1)) ->method('addMethodCall') ->with('setReplace', [true]); $definition ->expects($this->once()) ->method('addMethodCall') ->with('addSchema', [new Reference('test')]); $container ->expects($this->once()) ->method('hasDefinition') ->with(Services::SCHEMA) ->will($this->returnValue(true)); $container ->expects($this->at(1)) ->method('getDefinition') ->with(Services::SCHEMA) ->will($this->returnValue($definition)); $container ->expects($this->at(3)) ->method('getDefinition') ->with('test') ->will($this->returnValue($testDefinition)); $container ->expects($this->once()) ->method('findTaggedServiceIds') ->with(Services::SCHEMA) ->will($this->returnValue([ 'test' => [ ['replace' => true, 'reference' => true] ] ])); (new SchemaService())->process($container); } /** * @covers \Heystack\Core\DependencyInjection\CompilerPass\SchemaService::process */ public function testProcessNoDefinition() { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $container ->expects($this->once()) ->method('hasDefinition') ->with(Services::SCHEMA) ->will($this->returnValue(false)); $container ->expects($this->never()) ->method('getDefinition'); (new SchemaService())->process($container); } } |