dimanche 19 juillet 2015

Laravel 5: Controller Testing - PHPUnit returns green

the following simple controller test makes a 'GET' request to the PostsController@index action:

<?php 

class PostsControllerTest extends TestCase {

    public function testIndex()
    {
        $response = $this->action('GET', 'PostsController@index');

    }
}

In my understanding, if the index method does not exist in my controller, I shouldn't get the green light, when calling phpunit in my command line.

Yet my controller looks like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class PostsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    // public function index()
    // {
    //    //
    //    return 'Posts Index';
    //}
}

As you can clearly see the index method is commented out and I still get this:

**OK (1 test, 0 assertions)**

Any suggestions?

Aucun commentaire:

Enregistrer un commentaire