Skip to content

Commit 08e5d25

Browse files
committed
Added readme
1 parent 798d62a commit 08e5d25

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ class BundleInitializationTest extends BaseBundleTestCase
7272

7373
```
7474

75+
## Private services in Symfony 4
76+
77+
In Symfony 4 services are private by default. This is a good thing, but in order to test them properly we need to make
78+
them public when we are running the tests. This can easily be done with a compiler pass.
79+
80+
```php
81+
class BundleInitializationTest extends BaseBundleTestCase
82+
{
83+
protected function setUp()
84+
{
85+
parent::setUp();
86+
87+
// Make all services public
88+
$this->addCompilerPass(new PublicServicePass());
89+
90+
// Make services public that have an idea that matches a regex
91+
$this->addCompilerPass(new PublicServicePass('|my_bundle.*|'));
92+
}
93+
94+
// ...
95+
}
96+
```
97+
7598
## Configure Travis
7699

77100
You want Travis to run against each currently supported LTS version of Symfony (since there would be only one per major version), plus the current if it's not an LTS too. There is no need for testing against version in between because Symfony follows [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

0 commit comments

Comments
 (0)