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.

Revisions

  1. jaggy created this gist Aug 6, 2020.
    26 changes: 26 additions & 0 deletions SetupTraits.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <?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]);
    }
    }
    }