diff --git a/src/StickyContext.php b/src/StickyContext.php index 26795f4..f0f4401 100644 --- a/src/StickyContext.php +++ b/src/StickyContext.php @@ -46,7 +46,9 @@ public static function add($key, $data) */ public static function all() { - return static::$data; + return array_map(function ($value) { + return is_callable($value) ? $value() : $value; + }, static::$data); } /** diff --git a/tests/StickyContextProcessorTest.php b/tests/StickyContextProcessorTest.php index 43f9cc4..9768032 100644 --- a/tests/StickyContextProcessorTest.php +++ b/tests/StickyContextProcessorTest.php @@ -9,7 +9,7 @@ class StickyContextProcessorTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() { require __DIR__ .'/../vendor/autoload.php'; - parent::setUpBeforeClass(); // TODO: Change the autogenerated stub + parent::setUpBeforeClass(); } public function test_it_does_not_add_sticky_data_if_none_is_available() diff --git a/tests/StickyContextTest.php b/tests/StickyContextTest.php new file mode 100644 index 0000000..e22b39f --- /dev/null +++ b/tests/StickyContextTest.php @@ -0,0 +1,21 @@ +assertEquals(['arya' => 'Stark'], StickyContext::all()); + } +}