Functions\when()
.when()
and 5 related methods are used to define functions (if not defined yet) and:use
statement is in place:justReturn()
when()
in combination with justReturn()
you can make a (maybe) undefined function just return a given value:justReturn()
the target function will return nothing (null
).returnArg()
when
-related method is used to make the target function return one of the received arguments, by default the first.returnArg()
throws an exception:justEcho()
justReturn()
, it makes the mocked function echo some value instead of returning it.echoArg()
returnArg()
, it makes the mocked function echo some received argument instead of returning it.alias()