Giter Club home page Giter Club logo

Comments (7)

xabbuh avatar xabbuh commented on August 15, 2024

@boekkooi Can you explain how your container looked like when you were not able to dump it?

from symfonydependencyinjectiontest.

boekkooi avatar boekkooi commented on August 15, 2024

A simple way to create a undumpable container is to set a instance as a service argument.
For example:

class MyExtension extends Extension
{
    /**
     * @inheritdoc
     */
    public function load(array $config, ContainerBuilder $container)
    {
....
        $def = new Definition('stdClass');
        $def->addArgument(new \stdClass());
        $container->setDefinition('test', $def);
....
    }
}

This has happened for example here boekkooi/tactician-amqp-bundle@af60508

from symfonydependencyinjectiontest.

xabbuh avatar xabbuh commented on August 15, 2024

I see, that's something that would indeed be caught by such a test. However, such a test would also fail under other circumnstances where you would not expect it or were it doesn't matter for your application. Ffor example, the YAML dumper does not support anonymous services (which is perfectly fine when dumping to PHP or XML).

from symfonydependencyinjectiontest.

boekkooi avatar boekkooi commented on August 15, 2024

Good point still maybe reworking the assert to accept the type of dumper would be a good idea then again nobody is forced to use the assert 😄 I was just wondering if creating a PR for this would be a good idea.

So make it something like protected function assertContainerCanBeDumpedAs($type = 'php')?

from symfonydependencyinjectiontest.

matthiasnoback avatar matthiasnoback commented on August 15, 2024

@boekkooi Thanks for bringing this up. However, as can be seen here: https://github.com/matthiasnoback/SymfonyDependencyInjectionTest/blob/master/PhpUnit/AbstractContainerBuilderTestCase.php#L18 the test scenario isn't a very realistic one so I doubt how much trust in an extension class this new assertion will bring us. If you want to be sure that a container can be dumped, you should create a test kernel and register your bundle as well as other bundles that are needed for successful execution. While booting that test kernel it will also be dumped to afaik PHP and XML (maybe in a temporary directory, but at least you will catch any exceptions caused by dumping it).

from symfonydependencyinjectiontest.

boekkooi avatar boekkooi commented on August 15, 2024

@matthiasnoback Thanks for the response. It was just a idea and you are correct a kernel would be the best solution. Thank you for taking the time!

from symfonydependencyinjectiontest.

matthiasnoback avatar matthiasnoback commented on August 15, 2024

@boekkooi Thanks for an interesting discussion! See you next time :)

from symfonydependencyinjectiontest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.