laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

Access badges when testing #2416

Open LocalHeroPro opened 3 years ago

LocalHeroPro commented 3 years ago

When I use in controller:

return back()->with('status', ['type' => 'success', 'message' => __('The settings have been updated.')]);

How I can check what I received in response? I try:

$a = $session->baseResponse;
$b = $a->session;

but get in terminal:

PHPUnit 9.4.2 by Sebastian Bergmann and contributors.

array:3 [
  "_token" => "ANrtLX7nKOYnXE44UxRGuBUdnvMSBfkN9TnPmSen"
  "status" => array:2 [
    "type" => "success"
    "message" => "The settings have been updated."
  ]
  "_flash" => array:2 [
    "new" => []
    "old" => array:1 [
      0 => "status"
    ]
  ]
]

Error : Cannot access protected property Illuminate\Http\RedirectResponse::$session

So terminal showing for me protected propertys ;) But I want get access to that propertys and after that assert them, with something similar:

self::assertEquals($b['status']['message'], __('The settings have been updated.')).