Skip to content

Instantly share code, notes, and snippets.

@jaggy
Created August 6, 2020 08:48
Show Gist options
  • Save jaggy/0bb7b68d1868948c05e433549eaa5d4c to your computer and use it in GitHub Desktop.
Save jaggy/0bb7b68d1868948c05e433549eaa5d4c to your computer and use it in GitHub Desktop.
<?php
namespace Tests\SetupTraits;
trait SetupTraits
{
protected function setUpTraits()
{
$this->setupAdditionalTraits(
parent::setUpTraits()
);
}
protected function setupAdditionalTraits($uses)
{
foreach($uses as $trait) {
$method = 'setup' . class_basename($trait);
if (! method_exists($this, $method)) {
continue;
}
call_user_func([$this, $method]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment