File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
src/Illuminate/Foundation/Testing Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,14 @@ protected function setUpTraits()
143143 $ this ->setUpFaker ();
144144 }
145145
146+ foreach ($ uses as $ trait ) {
147+ $ method = 'setUp ' .class_basename ($ trait );
148+
149+ if (method_exists ($ this , $ method )) {
150+ $ this ->{$ method }();
151+ }
152+ }
153+
146154 return $ uses ;
147155 }
148156
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Illuminate \Tests \Foundation \Testing ;
4+
5+ use Illuminate \Foundation \Testing \TestCase as FoundationTestCase ;
6+ use Orchestra \Testbench \Concerns \CreatesApplication ;
7+ use PHPUnit \Framework \TestCase ;
8+
9+ trait TestTrait
10+ {
11+ public $ booted = false ;
12+
13+ public function setUpTestTrait ()
14+ {
15+ $ this ->booted = true ;
16+ }
17+ }
18+
19+ class TestCaseWithTrait extends FoundationTestCase
20+ {
21+ use CreatesApplication;
22+ use TestTrait;
23+ }
24+
25+ class BootTraitsTest extends TestCase
26+ {
27+ public function testSetUpTraitsWithBootMethod ()
28+ {
29+ $ testCase = new TestCaseWithTrait ;
30+
31+ $ method = new \ReflectionMethod (get_class ($ testCase ), 'setUpTraits ' );
32+ tap ($ method )->setAccessible (true )->invoke ($ testCase );
33+
34+ $ this ->assertTrue ($ testCase ->booted );
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments