Comments (7)
@boekkooi Can you explain how your container looked like when you were not able to dump it?
from symfonydependencyinjectiontest.
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.
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.
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.
@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.
@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.
@boekkooi Thanks for an interesting discussion! See you next time :)
from symfonydependencyinjectiontest.
Related Issues (20)
- failed to load vendor/autoload.php HOT 1
- LoaderFactory supporting .yaml extension
- Incompatibility with phpunit 8 HOT 2
- $container->getExtensionConfig() does not return minimal configuration
- Support for Symfony 5 HOT 3
- Assert container does not have a method call
- Lots of composer deprecation warnings about PSR-4 compliance HOT 2
- PHP8 Support HOT 1
- New release HOT 1
- False positive with assertContainerBuilderHasServiceDefinitionWithArgument
- Remove supported for Symfony 2.3 HOT 5
- Allow test DI-extenions that depends on another extensions and config
- it_lower_cases_aliased_service_ids fails HOT 2
- Next release HOT 1
- Add support for Symfony 4
- Investigate in build failure HOT 2
- Support tests for "Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface" HOT 1
- Add phpunit as a non-dev depedency. HOT 2
- 1.2.0 is not BC with 1.1.* HOT 3
- Declaration of Matthias\SymfonyDependencyInjectionTest\PhpUnit\DefinitionHasMethodCallConstraint::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString(): string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symfonydependencyinjectiontest.