Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context is lost after $recursionLimit messages #5

Open
AdrianSchneider opened this issue May 20, 2021 · 0 comments
Open

Context is lost after $recursionLimit messages #5

AdrianSchneider opened this issue May 20, 2021 · 0 comments

Comments

@AdrianSchneider
Copy link

If you set some context, and then log it more than StickyContextStack::$recursionLimit times, the context is lost.

Test case:

    public function test_it_can_retain_sticky_data()
    {
        $stack = new StickyContextStack();
        StickyContextStack::$recursionLimit = 3;

        $stack->add('username', 'aryastark');
        $this->assertEquals(['username' => 'aryastark'], $stack->all());
        $this->assertEquals(['username' => 'aryastark'], $stack->all());
        $this->assertEquals(['username' => 'aryastark'], $stack->all());

        // fails
        $this->assertEquals(['username' => 'aryastark'], $stack->all());
    }

Output:

Time: 19 ms, Memory: 4.00 MB

There was 1 failure:

1) StickyContextStackTest::test_it_can_retain_sticky_data
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    'username' => 'aryastark'
 )

Looking at the code, it never resets the counter anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant