diff --git a/src/Illuminate/Foundation/Testing/TestCase.php b/src/Illuminate/Foundation/Testing/TestCase.php index d7e92b557288..34aa06582d4d 100644 --- a/src/Illuminate/Foundation/Testing/TestCase.php +++ b/src/Illuminate/Foundation/Testing/TestCase.php @@ -143,6 +143,14 @@ protected function setUpTraits() $this->setUpFaker(); } + foreach ($uses as $trait) { + $method = 'setUp'.class_basename($trait); + + if (method_exists($this, $method)) { + $this->{$method}(); + } + } + return $uses; } diff --git a/tests/Foundation/Testing/BootTraitsTest.php b/tests/Foundation/Testing/BootTraitsTest.php new file mode 100644 index 000000000000..b26d66481152 --- /dev/null +++ b/tests/Foundation/Testing/BootTraitsTest.php @@ -0,0 +1,36 @@ +booted = true; + } +} + +class TestCaseWithTrait extends FoundationTestCase +{ + use CreatesApplication; + use TestTrait; +} + +class BootTraitsTest extends TestCase +{ + public function testSetUpTraitsWithBootMethod() + { + $testCase = new TestCaseWithTrait; + + $method = new \ReflectionMethod(get_class($testCase), 'setUpTraits'); + tap($method)->setAccessible(true)->invoke($testCase); + + $this->assertTrue($testCase->booted); + } +}