Framework: $response->assertSee Does not work properly

Created on 29 Nov 2017  路  2Comments  路  Source: laravel/framework

  • Laravel Version: 5.5.21
  • PHP Version: 7.1.11
  • Database Driver & Version: MySQL 14.14 Distrib 5.7.17

Description:

$response->assertSee('Text') does not work properly if your controller action does not exists and you will get green instead of red because it's not throwing an exception

Steps To Reproduce:

  1. Create a Controller with php artisan make:controller Hello;

  2. Create the route defined in web.php

Route::get('/myaction', 'Hello@hello');

  1. Try to do some assertion to see Hello and you got green even the controller action method hello does not exists yet
public function test_if_controller_action_prints_hello()
    {
        $response = $this->get('/myaction');
        $response->assertSee('Hello');
    }

Most helpful comment

Is this passing because the error has the word "Hello".

i.e. the assertion is correct - because "Hello" is appearing on the page (the error message itself).

All 2 comments

I'm not sure if there is much the assertion can check for. Also it is recommended to check the status of the response when you do a $this->get() or any other call.

Is this passing because the error has the word "Hello".

i.e. the assertion is correct - because "Hello" is appearing on the page (the error message itself).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

progmars picture progmars  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

shopblocks picture shopblocks  路  3Comments

PhiloNL picture PhiloNL  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments