You can set the values there. It will get reset w...
# testing
e
You can set the values there. It will get reset when calling
setup()
.
w
I guess I still don’t get it. In my test I start with
Copy code
it( "shows TwoFactorActivationKey", function(){getFlashScope().put("userId",2, true );
                DEBUG(getFlashScope().getall());
                // Execute event or route via GET http method. Spice up accordingly
                var event = get(
                    "Users/showTwoFactorActivationKey",
                    {
                        tenantCode: "someTenant"
                    }
                );
In my handler I dump this userId like this:
Copy code
// retrieve from previous step
        var userId=flash.get("userId",-1);
        writedump(UserId);
I would assume my UserId would be 2 now, but it still shows up as -1. So probably I am doing something wrong. But what? Would be nice if there were some examples/documentation.
e
I apologize. It looks like the MockFlash is set up in the
BaseHandlerTest
and the
BaseInterceptorTest
, but not the
BaseTestCase
. I’ll see if we can get a PR for this.
w
Yes, that’s what I discovered. What’s the use of the BaseHandlerTest? In all workshops we didn’t use it
e
¯\_(ツ)_/¯
I don’t really use any of the other testing stubs. Luis might be able to fill in better.
w
So probably I should just add this to my setup
Copy code
variables.mockFlash  = mockBox
            .createMock( "coldbox.system.web.flash.MockFlash" )
            .init( mockController );
variables.mockRequestService.$( "getFlashScope", variables.mockFlash );
e
So, you could override the flash scope for testing —
Copy code
// config/ColdBox.cfc
function testing() {
    flash.scope = "mock";
}
Then, as long as you set the
ENVIRONMENT
to
testing
in some way it would load the mock flash.
w
Is there any specific var which i can detect for testing, so I can create my testing environment on the fly? I only have development, staging and production here now, and no separate testing environment yet. So I am abusing my dev environment for this now.
That’s at least better than no testing at all 😉 . I am really looking for more documentation. Even on cfcasts I can hardly find anything on mocking flash or the specific use or these different test classes. I must have been sleeping on my testbox workshop (which was 100 years ago)
But thanks for now Eric. Helpful, as always 👏👍