PHP code example of jdecool / atoum-symfony-di-extension

1. Go to this page and download the library: Download jdecool/atoum-symfony-di-extension library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jdecool / atoum-symfony-di-extension example snippets


namespace Vendor\MyProjectBundle\DependencyInjection\Tests\Units;

use atoum;
use Vendor\MyProjectBundle\DependencyInjection\VendorMyBundleExtension as TestedClass;
use Symfony\Component\DependencyInjection;

class VendorMyBundleExtension extends atoum
{
    public function testLoad()
    {
        $this
            ->given(
                $container = new DependencyInjection\ContainerBuilder(),
                $testedClass = new TestedClass(),
                $testedClass->load([], $container)
            )
            ->then
                ->containerBuilder($container)
                    ->hasService('myServiceName')
                    ->hasParameter('myParameterName')
        ;
    }
}



// .atoum.php

mfonyDependencyInjection;

$runner->addExtension(new symfonyDependencyInjection\extension($script));

$this
    ->containerBuilder($container)
        ->hasService('serviceId') // passes
        ->hasService('service_id') // fails
;

$this
    ->containerBuilder($container)
        ->hasSyntheticService('app.synthetic_service') // passes
        ->hasService('app.synthetic_service') // fails
        ->hasSyntheticService('app_synthetic_service') // fails
;

$this
    ->containerBuilder($container)
        ->hasService('service_id') // passes
        ->hasService('serviceId') // fails
;

$this
    ->containerBuilder($container)
        ->hasParameter('mailer.transport') // passes
        ->hasParameter('mailer_transport') // fails
;

$this
    ->containerBuilder($container)
        ->hasNotParameter('mailer_transport') // passes
        ->hasNotParameter('mailer.transport') // fails
;

$this
    ->containerBuilder($container)
        ->hasAlias('myAwesomeAlias') // passes
        ->hasAlias('anUnexistingAlias') // fails
;

$this
    ->serviceDefinition($container->getDefinition('serviceid'))
        ->isInstanceOf('ArrayObject') // passes
        ->isInstanceOf('SplFileObject') // fails
;

$this
    ->serviceDefinition($container->getDefinition('serviceid'))
        ->isNotInstanceOf('SplFileObject') // passes
        ->isNotInstanceOf('ArrayObject') // fails 
;

$this
    ->serviceDefinition($container->getDefinition('serviceid'))
        ->hasArgument(0)
;

$this
    ->serviceDefinition($container->getDefinition('serviceid'))
        ->hasTag('myCustomTag')
;

$this
    ->serviceDefinition($container->getDefinition('serviceid'))
        ->hasTag('myCustomTag')
;